def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) # create Window self.__benutzer = [] self.inputBenData() # Benutzer Name self.__ben_name = tk.StringVar() label_Ben_Name = tk.Label(self, text="Benutzer Name: ", font='bold,14', pady=20) label_Ben_Name.grid(row=0, column=0) benName_entry = tk.Entry(self, textvariable=self.__ben_name) benName_entry.grid(row=0, column=1) # Benutzer Vorname self.__ben_vname = tk.StringVar() label_Ben_Vname = tk.Label(self, text="Benutzer Vorname: ", font='bold,14', pady=20) label_Ben_Vname.grid(row=1, column=0) benVname_entry = tk.Entry(self, textvariable=self.__ben_vname) benVname_entry.grid(row=1, column=1) # Button add_btn = tk.Button(self, text='Add Benutzer', command=self.addItem) add_btn.grid(row=2, column=0, pady=20) del_btn = tk.Button(self, text='Delete Benutzer', command=self.delItem) del_btn.grid(row=2, column=1) update_btn = tk.Button(self, text='Update Benutzer', command=self.updateItem) update_btn.grid(row=2, column=2) save_btn = tk.Button(self, text='Save', command=self.save) save_btn.grid(row=2, column=4) help_btn = tk.Button(self, text='Help', command=self.help) help_btn.grid(row=6, column=3, pady=10)
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self.__benutzer = [] self.__filme = [] self.inputData() # Film Title self.__ben_name = tk.StringVar() label_ben_name = tk.Label(self, text="Benutzer Name: ", font='bold,14', pady=10) label_ben_name.grid(row=0, column=0) film_name_entry = tk.Entry(self, textvariable=self.__ben_name) film_name_entry.grid(row=0, column=1) # Film Jahr self.__bestell = tk.StringVar() label_bestell = tk.Label(self, text="Bestellung: ", font='bold,14', pady=10) label_bestell.grid(row=1, column=0) bestell_entry = tk.Entry(self, textvariable=self.__bestell) bestell_entry.grid(row=1, column=1) # Film Wertung self.__film_wertung = tk.StringVar() label_film_wertung = tk.Label(self, text="Wertung: ", font='bold,14', pady=10) label_film_wertung.grid(row=2, column=0) film_wertung_entry = tk.Entry(self, textvariable=self.__film_wertung) film_wertung_entry.grid(row=2, column=1) # Film sch self.__film_schauspieler = tk.StringVar() label_film_schauspieler = tk.Label(self, text="Schauspieler: ", font='bold,14', pady=10) label_film_schauspieler.grid(row=4, column=0) film_schauspieler_entry = tk.Entry( self, textvariable=self.__film_schauspieler) film_schauspieler_entry.grid(row=4, column=1) # Button print_btn = tk.Button(self, text='Benutzer Anzeigen', command=self.printItem) print_btn.grid(row=1, column=3) add_btn = tk.Button(self, text='Anzeigen Schauspiller', command=self.addItem) add_btn.grid(row=0, column=3, pady=20, padx=50) update_btn = tk.Button(self, text='Anzeigen Filme Wertung', command=self.updateItem) update_btn.grid(row=2, column=3) clear_btn = tk.Button(self, text='Bestellen', command=self.clearItem) clear_btn.grid(row=4, column=3) save_btn = tk.Button(self, text='Save', command=self.save) save_btn.grid(row=5, column=3, pady=10) help_btn = tk.Button(self, text='Help', command=self.help) help_btn.grid(row=6, column=3, pady=10)
def __init__(self, *args, **kwargs): Page.__init__(self, name="page1", *args, **kwargs) self.master.geometry("510x400") self.master.update() #The next part makes the use of grid easier #The idea is to use many squares like large pixels grid_len = [x for x in range(30)] minsize = (self.master.winfo_width() / 30, self.master.winfo_height() / 30) self.columnconfigure( grid_len, minsize=minsize[0], weight=1, ) self.rowconfigure( grid_len, minsize=minsize[1], weight=1, ) self.main_frame = tk.Frame( self, relief="sunken", border=1, ) self.main_frame.grid( column=1, row=1, sticky="NSEW", columnspan=28, rowspan=28, ) self.main_frame.update() grid_len = [x for x in range(30)] minsize = (self.main_frame.winfo_width() / 32, self.main_frame.winfo_height() / 30) self.main_frame.rowconfigure(grid_len, minsize=minsize[1], weight=1) self.label_main = tk.Label( self, text="Universe", font=("Consolas", "13", "bold"), ) self.label_main.grid(row=0, rowspan=3, column=1, columnspan=5, sticky="N") self.main_frame.columnconfigure( grid_len + [30, 31], minsize=minsize[0], weight=1, ) self.make_navigation_buttons(forward="page1_1", backward="main_page") self.forward_button.grid( row=27, column=28, rowspan=2, columnspan=2, sticky="NSEW", ) self.backward_button.grid( row=27, column=26, rowspan=2, columnspan=2, sticky="NSEW", ) #The next function ensures that plots are deleted #This is done for efficiency purpuses self.backward_button.config(command=lambda: [ self.box_interactive.set(False), self.update_box(), self.change_page("main_page") (), #Note the ()!!! Change page is a wraper! ]) self.forward_button.config(command=lambda: [ self.box_interactive.set(False), self.update_box(), self.change_page("page1_1") (), #Note the ()!!! Change page is a wraper! ]) ############################################################### #####The follwoing lines are exclusive to this page############ ############################################################### ############################################################### ############################################################### #####The follwoing lines are exclusive to this page############ ############################################################### ############################################################### ############################################################### #####The follwoing lines are exclusive to this page############ ############################################################### ############################################################### #These two will just help the code stay cleaner in the #following lines self.font = ("Consolas", "10", "bold") self.gridparams = dict(column=1, columnspan=8, rowspan=2, sticky="w") self.time_label = tk.Label( self.main_frame, text="Display time", font=self.font, justify="left", ) self.time_label.grid(row=2, **self.gridparams) self.stars_label = tk.Label( self.main_frame, text="Show stars", font=self.font, justify="left", ) self.stars_label.grid(row=5, **self.gridparams) #Follows number of dimensions label self.nd_label = tk.Label( self.main_frame, text="N dimensions", font=self.font, justify="left", ) self.nd_label.grid(row=8, **self.gridparams) self.init_t_label = tk.Label( self.main_frame, text="Initial t", font=self.font, justify="left", ) self.init_t_label.grid(row=11, **self.gridparams) self.init_dt_label = tk.Label( self.main_frame, text="Initial dt", font=self.font, justify="left", ) self.init_dt_label.grid(row=14, **self.gridparams) #Label for the physical dimensions of the universe self.uni_dims_label = tk.Label( self.main_frame, text='Side length', font=self.font, justify="left", ) self.uni_dims_label.grid(row=17, **self.gridparams) self.title_label = tk.Label( self.main_frame, text="Universe's name", font=self.font, justify="left", ) self.title_label.grid(row=20, **self.gridparams) self.blit_label = tk.Label( self.main_frame, text="Blit? (3D only)", font=self.font, justify="left", ) self.blit_label.grid(row=23, **self.gridparams) #I am now giving this variable a new value because the #old ones are now useless self.gridparams = dict( column=8, rowspan=2, columnspan=6, ) self.show_time = tk.BooleanVar() self.show_time.set(True) self.time_cb = ttk.Checkbutton( self.main_frame, variable=self.show_time, text="yes", onvalue=True, offvalue=False, takefocus=0, ) self.time_cb.grid(row=2, **self.gridparams) self.show_stars = tk.BooleanVar() self.show_stars.set(True) self.stars_cb = ttk.Checkbutton( self.main_frame, variable=self.show_stars, text="yes", onvalue=True, offvalue=False, takefocus=0, ) self.stars_cb.grid(row=5, **self.gridparams) #Radiobutton for 2 dimensions self.num_dims = tk.IntVar() self.num_dims.set(3) self.R2 = ttk.Radiobutton(self.main_frame, variable = self.num_dims, text = "2", value = 2, takefocus = 0, command = \ lambda: self.blit_cb.grid_forget() ) self.R2.grid( row=8, column=self.gridparams["column"] + 1, rowspan=self.gridparams["rowspan"], columnspan=3, sticky="w", ) self.R3 = ttk.Radiobutton(self.main_frame, variable = self.num_dims, text = "3", value = 3, takefocus = 0, command = \ lambda: self.blit_cb.grid( row = 23, **self.gridparams) ) self.R3.grid( row=8, column=self.gridparams["column"] + 2, rowspan=self.gridparams["rowspan"], columnspan=3, sticky="e", ) self.init_t_entry = ttk.Entry( self.main_frame, width=10, ) self.init_t_entry.insert(0, "0") self.init_t_entry.grid(row=11, **self.gridparams) self.init_dt_entry = ttk.Entry( self.main_frame, width=10, ) self.init_dt_entry.grid(row=14, **self.gridparams) self.init_dt_entry.insert(0, "0.01") self.uni_dims_entry = ttk.Entry( self.main_frame, width=10, ) self.uni_dims_entry.grid(row=17, **self.gridparams) self.uni_dims_entry.insert(0, "2000") self.title_entry = ttk.Entry( self.main_frame, width=10, ) self.title_entry.grid(row=20, **self.gridparams) self.title_entry.insert(0, "Predru's world") self.blit = tk.BooleanVar() self.blit.set(False) self.blit_cb = ttk.Checkbutton( self.main_frame, variable=self.blit, text="yes", onvalue=True, offvalue=False, takefocus=0, ) self.blit_cb.grid(row=23, **self.gridparams) self.optionmenustyle = ttk.Style() self.optionmenustyle.configure( "new_option.TMenubutton", background="white", ) self.units_t = tk.StringVar() units = "ms, s, min, hour, day, month, year".split(", ") self.init_t_drop = ttk.OptionMenu(self.main_frame, self.units_t, "s", *units, style="new_option.TMenubutton") self.init_t_drop.grid( row=11, column=self.gridparams["column"] + 5, columnspan=self.gridparams["columnspan"], rowspan=2, ) self.units_dt = tk.StringVar() units = "μm, ms, s, min, hour, day, month, year".split(", ") self.init_dt_drop = ttk.OptionMenu(self.main_frame, self.units_dt, "s", *units, style="new_option.TMenubutton") self.init_dt_drop.grid( row=14, column=self.gridparams["column"] + 5, columnspan=self.gridparams["columnspan"], rowspan=2, ) self.units_d = tk.StringVar() self.units_d_ = "nm, μm, mm, cm, dm, m, km, Mm, Gm".split(", ") self.units_d_drop = ttk.OptionMenu(self.main_frame, self.units_d, "m", *self.units_d_, style="new_option.TMenubutton") self.units_d_drop.grid( row=17, column=self.gridparams["column"] + 5, columnspan=self.gridparams["columnspan"], rowspan=2, ) self.question_icon = ImageTk.PhotoImage(IMAGES["question_icon"].resize( (24, 24))) row = 2 col = 18 rowspan = 2 columnspan = 2 for x in range(8): but = tk.Button( self.main_frame, border=0, image=self.question_icon, ) but.grid(column=col, row=row, columnspan=columnspan, rowspan=rowspan) row += 3 setattr(self, f"help_b{x}", but) self.give_function_to_help_bs() self.box_img = ImageTk.PhotoImage(IMAGES['box_icon'].resize( (154, 155))) self.box_lab = ttk.LabelFrame( self.main_frame, text="Visuals", ) self.box_labin = tk.Label(self.box_lab, image=self.box_img) self.box_labin.pack(side="left") self.box_lab.grid(row=2, column=21, rowspan=15, columnspan=10) #Update button self.button_style = ttk.Style() self.button_style.configure("Mybt.TButton", highlightbackground="green", background=self.master['background'], highlightcolor="green", foreground="green", font=("Consolas", "11", "bold")) self.update_b = ttk.Button( self.main_frame, text="Make universe", style="Mybt.TButton", command=lambda: [ setattr(self, "universe_dict", self.get_values()), print(self.universe_dict) ], takefocus=False, ) self.update_b.grid(row=17, column=21, columnspan=10, rowspan=3, sticky="NSEW") self.premade_button = ttk.Button( master=self.main_frame, text="Premade", command=lambda: print("Does not do anything yet!"), style="Mybt.TButton", ) self.premade_button.grid(row=20, column=21, columnspan=10, rowspan=3, sticky="NSEW") self.box_interactive = tk.BooleanVar() self.interactive_check = ttk.Checkbutton(self.main_frame, variable=self.box_interactive, text="Interactive", onvalue=True, offvalue=False, takefocus=0, command=self.update_box) self.interactive_check.grid(row=0, column=20, columnspan=7, rowspan=2, sticky="S") self.grid_forget()
def __init__(self, *args, **kwargs): Page.__init__(self, name="page4", *args, **kwargs) self.master.geometry("510x400") self.master.update() #The next part makes the use of grid easier #The idea is to use many squares like large pixels grid_len = [x for x in range(30)] minsize = (self.master.winfo_width() / 30, self.master.winfo_height() / 30) self.columnconfigure( grid_len, minsize=minsize[0], weight=1, ) self.rowconfigure( grid_len, minsize=minsize[1], weight=1, ) self.main_frame = tk.Frame(self, relief="sunken", border=1) self.main_frame.grid( column=1, row=1, sticky="NSEW", columnspan=22, rowspan=28, ) self.main_frame.update() grid_len = [x for x in range(30)] minsize = (self.main_frame.winfo_width() / 30, self.main_frame.winfo_height() / 30) self.main_frame.rowconfigure(grid_len, minsize=minsize[1], weight=1) self.main_frame.columnconfigure( grid_len, minsize=minsize[0], weight=1, ) self.make_navigation_buttons(forward="page2", backward="main_page") self.backward_button.config( command=lambda: [self.delete_canvas(), self.change_page("main_page")()]) self.forward_button.grid( row=27, column=28, rowspan=2, columnspan=2, sticky="NSEW", ) self.backward_button.grid( row=27, column=26, rowspan=2, columnspan=2, sticky="NSEW", ) ############################################################### #####The follwoing lines are exclusive to this page############ ############################################################### ############################################################### ############################################################### #####The follwoing lines are exclusive to this page############ ############################################################### ############################################################### ############################################################### #####The follwoing lines are exclusive to this page############ ############################################################### ############################################################### self.make_clock_b = ttk.Button(self, text="Make clock", command=self.make_clock, takefocus=0) self.clock_but = ttk.Button(self, text="Play", takefocus=0, command=lambda: t.show_time(self)) self.clock_stop = ttk.Button( self, text="Stop", takefocus=0, command=lambda: setattr(self, "running", False)) self.clock_rem_b = ttk.Button( self, text="Remove", takefocus=0, command=self.delete_canvas, ) self.clock_but.grid(row=4, column=24, rowspan=2, columnspan=5) self.clock_stop.grid(row=6, column=24, rowspan=2, columnspan=5) self.make_clock_b.grid(row=2, column=24, rowspan=2, columnspan=5) self.clock_rem_b.grid(row=8, column=24, rowspan=2, columnspan=5) self.grid_forget()
def __init__(self, *args, **kwargs): Page.__init__(self, name='page3', *args, **kwargs) self.rowconfigure([x for x in range(30)], minsize=self.master.winfo_height() / 30, weight=1) self.columnconfigure([x for x in range(40)], weight=1, minsize=self.master.winfo_width() / 41) self.notebook = ttk.Notebook(self) self.notebook.grid(row=1, column=1, rowspan=28, columnspan=38, sticky="NSEW") self.main_frame = ttk.Frame(master=self.notebook, border=1) self.notebook.add(self.main_frame, text="Plot settings") self.main_frame.columnconfigure([x for x in range(40)], minsize=self.master.winfo_width() / 41, weight=1) self.main_frame.rowconfigure([x for x in range(30)], minsize=self.master.winfo_height() / 30, weight=1) self.make_navigation_buttons(False, "main page") self.backward_button.config(command=lambda: [ setattr(self, "running", False) if hasattr(self, "running") else None, setattr(self.universe, "running", False) if hasattr(self, "universe") else None, self.delete_canvas() if hasattr(self, "canvas") else None, self.delete_canvas(), self.change_page("main_page")(), self.master.geometry("510x400"), ]) self.backward_button.grid(row=27, column=37, rowspan=2, columnspan=2, sticky="NSEW") self.lower_frame = tk.Frame(self.main_frame, ) #bg = "orange") self.lower_frame.grid(row=24, rowspan=6, column=0, columnspan=40, sticky="NSEW") self.lower_frame.update() self.lower_frame.rowconfigure([x for x in range(8)], weight=0, minsize=self.lower_frame.winfo_height() / 8) self.lower_frame.columnconfigure( [x for x in range(65)], minsize=self.lower_frame.winfo_width() / 66, weight=1) self.play_icon = ImageTk.PhotoImage(IMAGES['play_icon'].resize( (17, 17))) self.replay_icon = ImageTk.PhotoImage(IMAGES['replay_icon'].resize( (17, 17))) self.pause_icon = ImageTk.PhotoImage(IMAGES['pause_icon'].resize( (17, 17))) self.font = ("Consolas", "11") self.play_button = ttk.Button(self.lower_frame, image=self.play_icon, command=self.play, takefocus=0) self.play_button.grid( row=1, column=1, columnspan=4, rowspan=3, sticky="NSEW", ) def grid(wid, command='x'): """Command == 'x' for widget next, Command == 'y' for widget below!""" c = wid.grid_info() col = c['column'] + c['columnspan'] if command == "x" else c[ 'column'] ro = c['row'] + c['rowspan'] if command == 'y' else c['row'] params = dict(row=ro, column=col, columnspan=c['columnspan'], rowspan=c['rowspan'], sticky='NSEW') return params self.stop_button = ttk.Button(self.lower_frame, image=self.pause_icon, command=self.stop, takefocus=0) self.stop_button.grid(**grid(self.play_button)) self.replay_button = ttk.Button( self.lower_frame, image=self.replay_icon, command=self.replay, takefocus=0, ) self.replay_button.grid(**grid(self.stop_button)) params = grid(self.play_button, "y") params['row'] += 1 params['columnspan'] += 2 params['rowspan'] += 2 s = ttk.Style() s.configure("Greeen.TButton", foreground="green", font=self.font) self.draw_button = ttk.Button( self.lower_frame, text= 'Draw', width=1, style = "Greeen.TButton", command = lambda: \ make_plot(self) if not hasattr(self, "canvas") else None, takefocus = 0, ) self.draw_button.grid(**params) s.configure("Red.TButton", foreground="red", font=('Consolas', "8")) self.erase_button = ttk.Button( self.lower_frame, text='Erase', style="Red.TButton", width=2, takefocus=0, command=lambda: [ setattr(self, "running", False) if hasattr(self, "running") else None, setattr(self.universe, "running", False) if hasattr(self, "universe") else None, self.delete_canvas() if hasattr(self, "canvas") else None, ]) self.erase_button.grid(**grid(self.draw_button)) params = grid(self.replay_button) params['column'] += 1 params['sticky'] = "W" self.dt_label = tk.Label(self.lower_frame, text='dt s', font=("Consolas", "8")) self.dt_label.grid(**params) self.k_label = tk.Label(self.lower_frame, text='k N/m', font=("Consolas", "8")) self.k_label.grid(**grid(self.dt_label, "y")) self.m_label = tk.Label(self.lower_frame, text='m kg', font=("Consolas", "8")) self.m_label.grid(**grid(self.k_label, "y")) self.dt_var = tk.DoubleVar() self.dt_var.set(0.1) self.dt_slider = ttk.Scale( self.lower_frame, variable=self.dt_var, from_=0.01, to=1.0, ) params = grid(self.dt_label) params['columnspan'] += 4 params['sticky'] = "NSEW" self.dt_slider.grid(**params) self.k_var = tk.DoubleVar() self.k_var.set(1.0) self.k_slider = ttk.Scale( self.lower_frame, variable=self.k_var, from_=0.01, to=10, ) self.k_slider.grid(**grid(self.dt_slider, "y")) self.m_var = tk.DoubleVar() self.m_var.set(1.0) self.m_slider = ttk.Scale( self.lower_frame, variable=self.m_var, from_=0.01, to=10, ) self.m_slider.grid(**grid(self.k_slider, "y")) params = grid(self.dt_slider) params['columnspan'] = 5 #params['sticky'] = "NSW" self.dt_show_var = tk.StringVar() self.dt_show_var.set("0.5") self.dt_show = tk.Label(master=self.lower_frame, textvariable=self.dt_show_var, font=("Consolas", "8")) self.dt_show.grid(**params) self.dt_slider.config(command=lambda s: [ self.update_shows(s, self.dt_show_var), self.update_dtmk('dt', s) ]) self.k_show_var = tk.StringVar() self.k_show_var.set("0.5") self.k_show = tk.Label(self.lower_frame, textvariable=self.k_show_var, font=("Consolas", "8")) self.k_show.grid(**grid(self.dt_show, "y")) self.k_slider.config( command=lambda s: [self.update_shows(s, self.k_show_var), self.update_dtmk("k", s)]) self.m_show_var = tk.StringVar() self.m_show_var.set("0.5") self.m_show = tk.Label(self.lower_frame, textvariable=self.m_show_var, font=("Consolas", "8")) self.m_show.grid(**grid(self.k_show, "y")) self.m_slider.config( command=lambda s: [self.update_shows(s, self.m_show_var), self.update_dtmk('m', s)]) params = grid(self.dt_show) params['rowspan'] = 9 params['columnspan'] = 10 s.configure("lbf.TLabelframe.Label", font=("Consolas", "8", "bold"), foreground="green") self.label_show = ttk.LabelFrame( self.lower_frame, text='Show', style="lbf.TLabelframe", ) self.label_show.grid(**params) self.innerf = tk.Frame(self.label_show) self.innerf.pack(expand=True, fill="both") self.innerf.update() self.innerf.columnconfigure([x for x in range(2)], minsize=self.innerf.winfo_height() / 2, weight=0) s.configure( 'my.TCheckbutton', font=("Consolas", "8", "bold"), ) self.ek_var = tk.BooleanVar() self.ek_var.set(True) self.ek_check = ttk.Checkbutton(self.innerf, text="EK", style="my.TCheckbutton", takefocus=0, variable=self.ek_var, command=self.update_visible) self.ek_check.grid(row=0, column=0, sticky="NSEW") self.ep_var = tk.BooleanVar() self.ep_var.set(True) self.ep_check = ttk.Checkbutton(self.innerf, text="EP", style="my.TCheckbutton", takefocus=0, variable=self.ep_var, command=self.update_visible) self.ep_check.grid(row=1, column=0, sticky="NSEW") self.et_var = tk.BooleanVar() self.et_var.set(True) self.et_check = ttk.Checkbutton(self.innerf, text="ET", style="my.TCheckbutton", takefocus=0, variable=self.et_var, command=self.update_visible) self.et_check.grid(row=2, column=0, sticky="NSEW") self.fx_var = tk.BooleanVar() self.fx_var.set(True) self.fx_check = ttk.Checkbutton(self.innerf, text="Fx", style="my.TCheckbutton", takefocus=0, variable=self.fx_var, command=self.update_visible) self.fx_check.grid(row=0, column=1, sticky="NSEW") self.fy_var = tk.BooleanVar() self.fy_var.set(True) self.fy_check = ttk.Checkbutton(self.innerf, text="Fy", style="my.TCheckbutton", takefocus=0, variable=self.fy_var, command=self.update_visible) self.fy_check.grid(row=1, column=1, sticky="NSEW") self.ft_var = tk.BooleanVar() self.ft_var.set(True) self.ft_check = ttk.Checkbutton(self.innerf, text="FT", style="my.TCheckbutton", takefocus=0, variable=self.ft_var, command=self.update_visible) self.ft_check.grid(row=2, column=1, sticky="NSEW") #self.color_drop() self.grid_forget()
def __init__(self, master, name="page1_2", *args, **kwargs): Page.__init__(self, name=name, master=master, *args, **kwargs) #Setting up the grid self.columnconfigure([x for x in range(30)], minsize=self.master.winfo_width() / 30, weight=1) self.rowconfigure([x for x in range(30)], minsize=self.master.winfo_height() / 30, weight=1) #Making the forward and backward buttons #We both know that forward wont do nothing. But it looks cool. self.make_navigation_buttons(forward="page1_1", backward="page1_1") ## self.forward_button.grid(row = 27, column = 28, ## rowspan = 2, columnspan = 2, ## sticky = "NSEW", ## ) self.backward_button.grid( row=27, column=27, rowspan=2, columnspan=2, sticky="NSEW", ) self.backward_button.config(command=lambda: [ self.delete_canvas(), self.del_colorbar(), self.master.geometry("510x400"), self.change_page("page1_1")(), ]) #Now we add the heading self.label_main = tk.Label( self, text="Simulation", font=("Consolas", "16", "bold"), ) self.label_main.grid(row=0, rowspan=2, column=13, columnspan=6, sticky="N") #Time to add the main frame. But first a nptebook self.notebook = ttk.Notebook(self, ) #Now we place the notebook self.notebook.grid( column=1, row=1, sticky="NSEW", columnspan=28, rowspan=28, ) self.notebook.lower() self.main_frame = ttk.Frame( self.notebook, border=1) #Where the simulation will play out. self.params_frame = ttk.Frame( self.notebook, border=1) #Deeper chaing and adding things to animation self.animation_frame = ttk.Frame( self.notebook, border=1) #Using funcanimation to save video or GIF #Now we add the pages to the notebooks. self.notebook.add(self.main_frame, text="Animation") self.notebook.add(self.params_frame, text="Parameters") self.notebook.add(self.animation_frame, text="Animation") #Now we move on to working on the main frame self.main_frame.columnconfigure( [x for x in range(30)], minsize=self.master.winfo_width() / 30, weight=1, ) self.main_frame.rowconfigure( [x for x in range(30)], minsize=self.master.winfo_height() / 30, weight=1, ) #Now we make the drawing area self.canvas_area = tk.Frame(self.main_frame, relief="sunken", border=1) self.canvas_area.grid(row=0, column=0, rowspan=27, columnspan=24, sticky="NSEW") #Now we work on the buttons in the bottom of the page. self.lower_frame = tk.Frame(self.main_frame) self.lower_frame.grid(row=27, rowspan=3, column=0, columnspan=30, sticky="NSEW") self.lower_frame.update() self.lower_frame.rowconfigure([x for x in range(6)], minsize=self.lower_frame.winfo_height() / 6, weight=0) self.lower_frame.columnconfigure( [x for x in range(19)], minsize=self.lower_frame.winfo_width() / 19, weight=0) self.lower_frame.columnconfigure( [0], minsize=self.lower_frame.winfo_width() / 80, weight=0) self.play_icon = ImageTk.PhotoImage(IMAGES['play_icon'].resize( (17, 17))) self.replay_icon = ImageTk.PhotoImage(IMAGES['replay_icon'].resize( (17, 17))) self.pause_icon = ImageTk.PhotoImage(IMAGES['pause_icon'].resize( (17, 17))) self.magnifying_icon = ImageTk.PhotoImage( IMAGES['magnifying_icon'].resize((17, 17))) self.star_icon = ImageTk.PhotoImage(IMAGES['star_icon'].resize( (17, 17))) self.play_button = ttk.Button(self.lower_frame, command=self.play, takefocus=0, image=self.play_icon) self.play_button.grid(row=1, column=1, rowspan=2, sticky="NSEW") self.stop_button = ttk.Button( self.lower_frame, image=self.pause_icon, command=self.stop, takefocus=0, ) self.stop_button.grid(row=1, rowspan=2, column=2, sticky="NSEW") self.replay_button = ttk.Button( self.lower_frame, command=self.replay, takefocus=0, image=self.replay_icon, ) self.replay_button.grid(row=1, rowspan=2, column=3, sticky="NSEW") self.time_icon = ImageTk.PhotoImage(IMAGES['time_icon'].resize( (17, 17))) self.path_button = ttk.Button( self.lower_frame, image=self.time_icon, command=self.show_path, takefocus=0, ) self.path_button.grid(row=1, rowspan=2, column=4, sticky="NSEW") self.stars_button = ttk.Button( self.lower_frame, command=self.turn_stars_on_off, takefocus=0, image=self.star_icon, ) self.stars_button.grid(row=1, rowspan=2, column=5, sticky="NSEW") self.zoom_button = ttk.Button(self.lower_frame, command=self.play_button["command"], takefocus=0, image=self.magnifying_icon) self.zoom_button.grid(row=1, rowspan=2, column=6, stick="NSEW") self.cmap_left_button = ttk.Button( self.lower_frame, text="-", takefocus=0, width=1, command=lambda: self.update_colorbar("-"), ) self.cmap_left_button.grid(row=3, rowspan=2, column=1, sticky="NSEW") self.cmap_icon = ImageTk.PhotoImage(IMAGES['cmap_icon'].resize( (110, 23))) self.cmap_label = tk.Label(self.lower_frame, image=self.cmap_icon) self.cmap_label.grid( row=3, column=2, columnspan=4, rowspan=2, sticky="NSEW", ) self.cmap_right_button = ttk.Button( self.lower_frame, text="+", takefocus=0, width=1, command=lambda: self.update_colorbar("+")) self.cmap_right_button.grid(row=3, rowspan=2, column=6, sticky="NSEW") # Making the slider pack for dt self.dt_label = tk.Label(self.lower_frame, text="dt", font=("Consolas", "8", "bold")) self.dt_label.grid( row=1, rowspan=2, column=7, sticky="NSEW", ) self.dt_text = tk.DoubleVar() self.dt_slider = ttk.Scale(self.lower_frame, from_=0., to=1, orient = "horizontal", variable = self.dt_text, command = lambda s: \ self.update_dt(s) ) self.dt_slider.set(0.5) self.dt_slider.grid(row=1, rowspan=2, column=8, columnspan=2, sticky="NSEW") self.dt_display = ttk.Label( self.lower_frame, textvar=self.dt_text, ) self.dt_display.grid(row=1, column=10, columnspan=1, rowspan=2, sticky="NSEW") self.scales = [f"* 1e{x} s" for x in range(-5, 5)] s = ttk.Style() s.configure("white2.TMenubutton", highlightbackground="white", background=self.master['background'], highlightcolor="white", bg="white", font=("Consolas", "5", "bold")) self.dt_drop = ttk.Combobox(self.lower_frame, values=self.scales, style="white2.TMenubutton", width=5, justify=tk.LEFT, takefocus=0, state='readonly') self.dt_drop.set("* 1e0 s") self.dt_drop.grid(row=1, rowspan=2, column=11, columnspan=2, sticky="NSEW") # Making the slider pack for number of cycles self.nc_label = tk.Label(self.lower_frame, text="n", font=("Consolas", "8", "bold")) self.nc_label.grid( row=3, rowspan=2, column=7, sticky="NSEW", ) self.nc_text = tk.DoubleVar() self.nc_slider = ttk.Scale(self.lower_frame, from_=0, to=10, orient = "horizontal", variable = self.nc_text, command = lambda s: \ self.update_cycles(s)) self.nc_slider.set(5) self.nc_slider.grid(row=3, rowspan=2, column=8, columnspan=2, sticky="NSEW") self.nc_display = ttk.Label( self.lower_frame, textvar=self.nc_text, ) self.nc_display.grid( row=3, column=10, columnspan=1, rowspan=2, sticky="NSEW", ) self.nc_scales = [f"* 1e{x} cycles" for x in range(0, 5)] s = ttk.Style() s.configure("white2.TMenubutton", highlightbackground="white", background=self.master['background'], highlightcolor="white", bg="white", font=("Consolas", "5", "bold")) self.nc_drop = ttk.Combobox(self.lower_frame, values=self.nc_scales, style="white2.TMenubutton", width=5, justify=tk.LEFT, takefocus=False, state="readonly") self.nc_drop.set("* 1e0 cycle") self.nc_drop.grid(row=3, rowspan=2, column=11, columnspan=2, sticky="NSEW") #Making the buttons that explain how dt and ncycles work question_icon = IMAGES['question_icon'].resize((15, 15)) self.question_icon = ImageTk.PhotoImage(question_icon) self.help_dt = tk.Button( self.lower_frame, image = self.question_icon, command = lambda: \ tk.messagebox.showinfo( "dt info", mdt), border = 0, ) self.help_dt.grid(row=1, rowspan=2, column=13, columnspan=1) self.help_nc = tk.Button( self.lower_frame, image = self.question_icon, command = lambda: \ tk.messagebox.showinfo( "dt info", m_cycles), border = 0, ) self.help_nc.grid(row=3, rowspan=2, column=13, columnspan=1) #Make a button to draw all the necessary canvas s = ttk.Style() self.font = ("Consolas", "10", "bold") s.configure("red.TButton", font=self.font, foreground="orangered") s.configure("green.TButton", font=self.font, foreground="green") self.make_canvas_but = ttk.Button(self.lower_frame, text="DRAW!", command=self.draw_simulation, takefocus=0, style="green.TButton") self.make_canvas_but.grid(row=1, rowspan=2, column=14, columnspan=2) self.erase_canvas_but = ttk.Button(self.lower_frame, text="ERASE!", takefocus=0, command=lambda: [ self.delete_canvas(), self.del_colorbar(), ], style="red.TButton") self.erase_canvas_but.grid(row=3, rowspan=2, column=14, columnspan=2) #This is a frame that holds the widgets on the right side of thepage. self.right_frame = tk.Frame( self.main_frame, bg="orange", ) self.right_frame.grid(row=0, column=24, rowspan=27, columnspan=6, sticky="NSEW") self.right_frame.update() self.right_frame.rowconfigure([0, 1], minsize = \ self.right_frame.winfo_height()/2, weight =1) self.right_frame.columnconfigure([0], minsize = \ self.right_frame.winfo_width(), weight =1) self.top_framelabel = ttk.LabelFrame( self.right_frame, text="Show", ) self.top_framelabel.grid( row=0, column=0, sticky="NSEW", ) self.top_framelabel.update() self.top_framelabel.rowconfigure( [x for x in range(8)], minsize=self.top_framelabel.winfo_height() / 9, weight=1) self.bottom_framelabel = ttk.LabelFrame(self.right_frame, text="Color by", border=1) self.bottom_framelabel.grid( row=1, column=0, sticky="NSEW", ) self.bottom_framelabel.rowconfigure( [x for x in range(8)], minsize=self.top_framelabel.winfo_height() / 9, weight=1) #Now we make a style for the checkbuttons below s = ttk.Style() s.configure("newCbt.TCheckbutton", font=("Consolas", "10")) self.p_var = tk.IntVar() self.planet_box = ttk.Checkbutton(self.top_framelabel, text="Planets", takefocus=False, style="newCbt.TCheckbutton", variable=self.p_var, command=self.update_displayed) self.planet_box.grid( row=0, column=0, sticky="NSEW", ) self.s_var = tk.IntVar() self.sun_box = ttk.Checkbutton(self.top_framelabel, text="Suns", takefocus=False, style="newCbt.TCheckbutton", variable=self.s_var, command=self.update_displayed) self.sun_box.grid(row=1, column=0, sticky="NSEW") self.m_var = tk.IntVar() self.moon_box = ttk.Checkbutton(self.top_framelabel, text="Moons", takefocus=False, style="newCbt.TCheckbutton", variable=self.m_var, command=self.update_displayed) self.moon_box.grid(row=2, column=0, sticky="NSEW") self.a_var = tk.IntVar() self.a_var.set(1) self.all_box = ttk.Checkbutton(self.top_framelabel, text="All", takefocus=False, style="newCbt.TCheckbutton", variable=self.a_var, command=self.update_displayed) self.all_box.grid(row=3, column=0, sticky="NSEW") self.o_var = tk.IntVar() self.other_box = ttk.Checkbutton(self.top_framelabel, text="Others", takefocus=False, style="newCbt.TCheckbutton", variable=self.o_var, command=self.update_displayed) self.other_box.grid(row=4, column=0, sticky="NSEW") # self.energies_box = ttk.Checkbutton( # self.top_framelabel, text = "Energies", # takefocus = False,style = "newCbt.TCheckbutton") # self.energies_box.grid(row =5, column=0, sticky = "NSEW") self.show_comp = tk.StringVar() self.show_comp.set("None") self.v_box = ttk.Radiobutton(self.bottom_framelabel, text="Speed", variable=self.show_comp, value="speed", takefocus=False, command=self.show_path) self.v_box.grid(row=0, column=0, sticky="NSEW") self.vx_box = ttk.Radiobutton(self.bottom_framelabel, text="Vx", takefocus=False, value="vx", variable=self.show_comp, command=self.show_path) self.vx_box.grid(row=1, column=0, sticky="NSEW") self.vy_box = ttk.Radiobutton(self.bottom_framelabel, text="Vy", takefocus=False, variable=self.show_comp, value="vy", command=self.show_path) self.vy_box.grid(row=2, column=0, sticky="NSEW") self.vz_box = ttk.Radiobutton(self.bottom_framelabel, text="Vz", takefocus=False, value="vz", variable=self.show_comp, command=self.show_path) self.vz_box.grid(row=3, column=0, sticky="NSEW") self.vnone_box = ttk.Radiobutton(self.bottom_framelabel, text="None", takefocus=False, value="None", variable=self.show_comp, command=self.show_path) self.vnone_box.grid(row=4, column=0, sticky="NSEW") #Now we make it possible to make a premade simulation from an #earlier page. THis was not done in the page to prevent dependency b = self.__class__.instances["page1"].premade_button b.config(command=lambda: Physics.threed(self)) self.grid_forget()
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self.__filme = [] self.inputFilmData() # Film Title self.__film_name = tk.StringVar() label_film_name = tk.Label(self, text="Film Name: ", font='bold,14', pady=10) label_film_name.grid(row=0, column=0) film_name_entry = tk.Entry(self, textvariable=self.__film_name) film_name_entry.grid(row=0, column=1) # Film Jahr self.__film_jahr = tk.StringVar() label_film_jahr = tk.Label(self, text="Jahr: ", font='bold,14', pady=10) label_film_jahr.grid(row=1, column=0) film_jahr_entry = tk.Entry(self, textvariable=self.__film_jahr) film_jahr_entry.grid(row=1, column=1) # Film Wertung self.__film_wertung = tk.StringVar() label_film_wertung = tk.Label(self, text="Wertung: ", font='bold,14', pady=10) label_film_wertung.grid(row=2, column=0) film_wertung_entry = tk.Entry(self, textvariable=self.__film_wertung) film_wertung_entry.grid(row=2, column=1) # Film Preis self.__film_preis = tk.StringVar() label_film_preis = tk.Label(self, text="Preis: ", font='bold,14', pady=10) label_film_preis.grid(row=3, column=0) film_preis_entry = tk.Entry(self, textvariable=self.__film_preis) film_preis_entry.grid(row=3, column=1) # Film sch self.__film_schauspieler = tk.StringVar() label_film_schauspieler = tk.Label(self, text="Schauspieler: ", font='bold,14', pady=10) label_film_schauspieler.grid(row=4, column=0) film_schauspieler_entry = tk.Entry( self, textvariable=self.__film_schauspieler) film_schauspieler_entry.grid(row=4, column=1) # Button print_btn = tk.Button(self, text='Filme Anzeigen', command=self.printItem) print_btn.grid(row=1, column=3) add_btn = tk.Button(self, text='Add Film', command=self.addItem) add_btn.grid(row=0, column=3, pady=20, padx=50) update_btn = tk.Button(self, text='Update Film', command=self.updateItem) update_btn.grid(row=2, column=3) save_btn = tk.Button(self, text='Save', command=self.save) save_btn.grid(row=3, column=3) help_btn = tk.Button(self, text='Help', command=self.help) help_btn.grid(row=4, column=3, pady=10)