python - Tkinter Dynamic Widget editing -


here code:

class render_window:     def __init__(self, height, width, window_title):         self.root_window = tk()         w = width         h = height         ws = self.root_window.winfo_screenwidth() # width of screen         hs = self.root_window.winfo_screenheight() # height of screen         x = (ws/2) - (w/2)         y = (hs/2) - (h/2)         self.root_window.title(window_title)         self.root_window.minsize(width, height)         self.root_window.geometry('%dx%d+%d+%d' % (w, h, x, y))      def new_button(self, button_text, button_command="", grid_row=0, grid_column=0, grid_sticky="nesw", grid_columnspan=1, grid_rowspan=1):         self.button = ttk.button(self.root_window, text=button_text, command=button_command)         self.button.grid(row=grid_row, column=grid_column, sticky=grid_sticky, columnspan=grid_columnspan, rowspan=grid_rowspan)         self.responsive_grid(grid_row, grid_column)      def new_label(self, label_text, text_alignment="center", grid_row=0, grid_column=0, grid_sticky="nesw", grid_columnspan=1, grid_rowspan=1):         self.label = ttk.label(self.root_window, text=label_text, anchor=text_alignment)         self.label.grid(row=grid_row, column=grid_column, sticky=grid_sticky, columnspan=grid_columnspan, rowspan=grid_rowspan)         self.responsive_grid(grid_row, grid_column)      def new_progress_bar(self, pg_length=250, pg_mode="determinate", grid_row=0, grid_column=0, grid_sticky="nesw", grid_columnspan=1, grid_rowspan=1):         self.progress_bar = ttk.progressbar(self.root_window, length=pg_length, mode=pg_mode)         self.progress_bar.grid(row=grid_row, column=grid_column, sticky=grid_sticky, columnspan=grid_columnspan, rowspan=grid_rowspan)         self.responsive_grid(grid_row, grid_column)      def responsive_grid(self, row_responsive=0, column_responsive=0, row_weight_num=1, column_weight_num=1):         self.root_window.grid_columnconfigure(column_responsive, weight=column_weight_num)         self.root_window.grid_rowconfigure(row_responsive, weight=row_weight_num)  options_window = render_window(200, 250, "options window")  options_window.new_progress_bar() options_window.progress_bar.start() options_window.new_progress_bar(grid_column=1) options_window.progress_bar.start() options_window.new_label("options window\and other buttons...", grid_row=1, grid_columnspan=2)  options_window.root_window.mainloop() 

i have created system allows creation of interface relatively using tkinter. having issue modifying of existing elements, cannot seem modify them if create multiple instances, can edit last 1 created. when modify/edit, talking .config().

so whenever do: options_window.progress_bar.config(args_here), last bar created. there way specify bar can execute code on?

thanks!

if understand correctly... not asign each progressbar variable? ie.

pb1 = options_window.progress_bar pb1.start() pb1.conig('etc, etc') 

sorry if have misunderstood problem!

ps - cool idea!


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -