def initUI(self): self.master.title("Interval Player") self.pack(fill=BOTH, expand = 1) openButton = Button(self, text = "Open", command=findFile) openButton.place(x=0, y=0)
def initialize_face_toggle_ui(self, face_locations, face_encodings, unique_encodings): # Initialize canvas canvas = tk.Canvas(self, width=400, height=250) canvas.place(y=0, relx=0.5, anchor=tk.N) # Initialize the strip below canvas strip = tk.Canvas(self, width=400, height=50, bg="#222222") strip.place(y=250, relx=0.5, anchor=tk.N) # Initialize blur toggle button blur_toggle_button = Button(self) blur_toggle_button.config(command=partial(self.toggle_blur, canvas, blur_toggle_button)) blur_toggle_button.place(y=275, x=200, anchor=tk.CENTER) # Initialize back arrow button back_button = Button(self, image=self.back_icon) back_button.config(command=partial(self.back, canvas, blur_toggle_button)) back_button.place(y=275, x=150, anchor=tk.CENTER) # Initialize forward arrow button forward_button = Button(self, image=self.forward_icon) forward_button.config(command=partial(self.forward, canvas, blur_toggle_button)) forward_button.place(y=275, x=250, anchor=tk.CENTER) # Initialize close button close_button = Button(self, command=self.cancel, image=self.close_icon) close_button.place(y=275, x=25, anchor=tk.CENTER) # Initialize done button done_button = Button(self, image=self.done_icon) done_button.config(command=partial(self.done, [back_button, forward_button, done_button, close_button, blur_toggle_button], face_locations, face_encodings, unique_encodings)) done_button.place(y=275, x=375, anchor=tk.CENTER) # Display first face image self.display_face(canvas, blur_toggle_button)
def initUI(self,initialText,title,labeltext=''): self.STID = initialText self.geometry("200x120") if len(title) > 0: self.title(title) self.style = Style() self.style.theme_use("default") # default style = Style() style.configure("Exit.TButton", foreground="red", background="white") style.configure("MainButton.TButton", foreground="yellow", background="red") if len(labeltext) == 0: labeltext = 'Please enter your ID..' self.bind("<Return>", self.ok) xpos = 40 ypos = 30 xpos2 = xpos+100 l1 = Label(self, text=initialText, foreground = "#ff0000", background = "light blue", font = "Arial 9") # Arial 12 bold italic l1.place(x=xpos, y=ypos) self.txtID = Entry(self) self.txtID.place(x=xpos2, y = ypos, width=70) self.txtID.bind("<Return>", self.ok) self.txtID.bind("<Escape>", self.cancel) self.txtID.focus_set() ypos += 30 okButton = Button(self, text="OK", background = "light blue", command=self.ok) #okButton.configure(style="ExitButton.TButton") # does not work okButton.place(x=xpos2, y=ypos)
def quitButton(self): self.style = Style() self.style.theme_use("default") quitButton = Button(self, text="Quit", command=self.quit) quitButton.place(x=50, y=50)
def main(): root = Tk() root.geometry("250x85+1250+650") app = Example() frame1 = Frame(root) frame1.pack(fill=BOTH) lbl1 = Label(frame1, text="Enter today's work") lbl1.pack(fill=X, padx=5, pady=5) frame2 = Frame(root) frame2.pack(fill=BOTH) entry1 = Entry(frame2) entry1.pack(fill=X, padx=5, expand=True) entry1.focus_set() def callback(): print(entry1.get()) print_values(entry1.get()) write_into_workbook(entry1.get()) frame3 = Frame(root) frame3.pack(fill=BOTH, expand=True) subbtn = Button(frame3, text="Done", command=callback) subbtn.place(x=4,y=5) root.mainloop()
def initItems_group1(self): """Placing images with place() method""" # A simple button to quit the program. quitButton = Button(self, text='Quit', command=self.quit) quitButton.place(x=5, y=5) # A simple picture. google_pic = tkinter.PhotoImage(file='images/google.png') ggl_lbl = tkinter.Label(self, image=google_pic) ggl_lbl.image = google_pic ggl_lbl.place(x=95, y=5) # Example of zooming picture. yandex_pic = tkinter.PhotoImage(file='images/yandex.png') yandex_pic = yandex_pic.zoom(2) yandexpic_panel = tkinter.Label(image=yandex_pic) yandexpic_panel.image = yandex_pic yandexpic_panel.place(x=170, y=5) # Example of resizing picture. ya_pic = tkinter.PhotoImage(file='images/yandex.png') ya_pic = ya_pic.subsample(x=2, y=2) # {x=1, y=1} is a original picture. yapic_panel = tkinter.Label(image=ya_pic) yapic_panel.image = ya_pic yapic_panel.place(x=240, y=5) # Add a separator for this and the next group. sep_pic = tkinter.PhotoImage(file='images/sep.png') sep_pic = sep_pic.subsample(x=1, y=1000) sep_lbl = tkinter.Label(image=sep_pic) sep_lbl.image = sep_pic sep_lbl.place(x=5, y=85)
def initUI(self): self.master.title("Choisce of Mode") #Title self.pack(fill=BOTH, expand=1) Style().configure("TFrame", background="#CCC") # list of texts for labels above the dual choice question box textbase = ["Choose the Scene Mode", "Are you ready to rec?", "Do you need a preview?"] # list of texts on left and right button, respectively buttonbase = ['General','Violence', 'Cancel','Record', 'Preview', 'Record'] # files of images should be 80x80 named qNl.png and qNr.png # for left and right Nth question, respectively imLeft = ImageTk.PhotoImage(Image.open('q' +str(QFlag)+'l.png')) imRight = ImageTk.PhotoImage(Image.open('q' +str(QFlag)+'r.png')) lbl2 = Label(text=textbase[QFlag-1], width=100, background="#CCC", foreground="black", font=("Courier", 12)) Button1 = Button(self, text=buttonbase[QFlag*2-2], command= self.leftbut) Button2 = Button(self, text=buttonbase[QFlag*2-1], command= self.rightbut) # positionning of components label1 = Label(self, image=imLeft) label1.image = imLeft label1.place(x=21, y=27) label2 = Label(self, image=imRight) label2.image = imRight label2.place(x=147, y=28) Button1.place(x=25, y=117) Button2.place(x=151, y=117) lbl2.place(x=18, y=3)
def initUI(self): self.parent.title("Image Copy-Move Detection") self.style = Style().configure("TFrame", background="#333") # self.style.theme_use("default") self.pack(fill=BOTH, expand=1) quitButton = Button(self, text="Open File", command=self.onFilePicker) quitButton.place(x=10, y=10) printButton = Button(self, text="Detect", command=self.onDetect) printButton.place(x=10, y=40) self.textBoxFile = Text(self, state='disabled', width=80, height = 1) self.textBoxFile.place(x=90, y=10) self.textBoxLog = Text(self, state='disabled', width=40, height=3) self.textBoxLog.place(x=90, y=40) # absolute image widget imageLeft = Image.open("resource/empty.png") imageLeftLabel = ImageTk.PhotoImage(imageLeft) self.labelLeft = Label(self, image=imageLeftLabel) self.labelLeft.image = imageLeftLabel self.labelLeft.place(x=5, y=100) imageRight = Image.open("resource/empty.png") imageRightLabel = ImageTk.PhotoImage(imageRight) self.labelRight = Label(self, image=imageRightLabel) self.labelRight.image = imageRightLabel self.labelRight.place(x=525, y=100) self.centerWindow()
def createFrame(self) -> None: # create save button saveBtn = Button(master=self, text="Save", command=self.submit) saveBtn.place(anchor='s', relx=0.5, rely=1, y=(-PAD)) # create containing frame lfrm = LFrame(master=self, text="Anime List") lfrm.place(anchor='n', relx=0.5, rely=0, y=PAD, relwidth=1, width=(-PAD * 2), relheight=1, height=(-PAD * 3 - saveBtn.winfo_reqheight())) # create scrolling frame self.scrFrm = SFrame(master=lfrm, scrollbars='e', padding=PAD, bd=0) self.scrFrm.place(anchor='nw', relx=0, relwidth=1, rely=0, relheight=1) self.scrFrm.columnconfigure(0, weight=1)
def initUI(self): self.master.title("GPIO Diagnostic Tool") self.pack(fill=BOTH, expand=1) self.centerWindow() quitButton = Button(self, text="Quit", command=self.quit) quitButton.place(x=50, y=50)
def config_question_screen(question_number): global question global next_btn global scale global answers global answer question = Label(window, text=questions[question_number]) w = len(questions[question_number]) * 7 w = set_good_width(w) h = 250 window.geometry('{}x{}'.format(w, h)) question.place(x=25, y=35) answer_text = "0 - " + answers[question_number][0] + " 5 - " + \ answers[question_number][1] + " 10 - " + answers[question_number][2] answer = Label(window, text=answer_text) answer.place(x=25, y=150) if question_number == 11: next_btn = Button(window, text="Завершить опрос", command=final_action) else: next_btn = Button(window, text="Следующий вопрос", command=next_question) scale = Scale(window, orient=HORIZONTAL, length=w - 75, from_=0, to=10, command=accept_whole_number_only) scale.place(x=25, y=85) place_digits_under_scale(w - 75) next_btn.place(x=w / 2 - 50, y=190)
def initUI(self): self.parent.title("Quit Button") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) quitButton = Button(self, text="Quit", command=self.quit) quitButton.place(x=0, y=475)
def __init__(self,parent): Frame.__init__(self,parent) self.parent = parent self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) loadButton = Button(self, text="Load Image" ,background = "light blue", command=self.openFile) #okButton.configure(style="ExitButton.TButton") # does not work loadButton.place(x=50, y=50)
def initUI(self): self.parent.title("Torrent Downloader") self.pack(fill=BOTH, expand=1) self.centerWindow() self.style = Style() self.style.theme_use("alt") self.pack(fill=BOTH, expand=1) quitButton = Button(self, text="Quit", command=self.quit) quitButton.place(x=50, y=50)
def initUI(self): self.style = Style() self.style.theme_use("clam") self.master.title("Quit Button") self.pack(fill=BOTH, expand=1) quitButton = Button(self, text="Quit", command=self.quit) quitButton.place(x=50, y=50)
def by_company_screen(): global graph_type, company_window graph_type = 0 company_window = Tk() company_window.title("По всей компании") company_window.geometry("1200x800") company_window.wm_geometry("+%d+%d" % (x-250, y-250)) graph_stat() save_butt = Button(company_window, text="Сохранить срез", command=save_departs_csv) save_butt.place(x=25, y=35)
class ChernobylStation(Frame): def __init__(self): super().__init__() self.frameMain = Frame(self, relief=RAISED, borderwidth=1) self.style = Style() self.valikko = ttk.Combobox(self.frameMain, values=list(sanakirja.keys())) self.label = tk.Label(self.frameMain, text="Select date from the drop down menu") self.closeButton = Button(self, text="Close", command=self.quit) self.searchButton = Button(self.frameMain, text="Search", command=lambda: self.plot()) self.initUI() def plot(self): self.label.configure(text=self.valikko.get()) def initUI(self): self.master.title("Chernobyl Control Station 1") self.style.theme_use("default") self.frameMain.pack(fill=BOTH, expand=True) self.label.place(x=100, y=80) self.valikko.place(x=80, y=120) self.searchButton.place(x=240, y=120) self.pack(fill=BOTH, expand=True) self.closeButton.pack(side=RIGHT, padx=5, pady=5) def rawTemp(self): f = open(tempSensor, 'r') lines = f.readlines() f.close() return lines def readTemp(self): lines = self.rawTemp() while lines[0].strip()[-3:] != 'YES': time.sleep(0.2) lines = self.rawTemp() tempOutput = lines[1].find('t=') if tempOutput != -1: tempString = lines[1].strip()[tempOutput + 2:] tempC = float(tempString) / 1000.0 tempF = tempC * 9.0 / 5.0 + 32.0 # print("Temperature in Celcius: ",tempC) # print("Temperature in Fahrenheit: ", tempF) return tempC def getDate(self): return self.date() def getTime(self): return self.time()
class Application_ui(Frame): # 这个类仅实现界面生成功能,具体事件处理代码在子类Application中。 def __init__(self, master=None): Frame.__init__(self, master) self.master.title('Excel转化Rpy工具') self.master.geometry('600x343') self.createWidgets() def createWidgets(self): self.top = self.winfo_toplevel() self.style = Style() self.bkg_gif = PhotoImage(data=base64.b64decode(back_ground_gif_data)) self.background_label = Label(self.top, image=self.bkg_gif) self.background_label.place(x=0, y=0, relwidth=1, relheight=1) self.Text = Text(self.top, font=('宋体', 9)) self.Text.place(relx=0.066, rely=0.07, relwidth=0.869, relheight=0.563) self.saveAddr = Entry(self.top, font=('宋体', 9)) self.saveAddr.place(relx=0.355, rely=0.84, relwidth=0.409, relheight=0.052) self.ComboList = ['源文件目录', '自定义目录'] self.Combo = Combobox(self.top, values=self.ComboList, font=('宋体', 9), state='readonly') self.Combo.place(relx=0.184, rely=0.84, relwidth=0.146, relheight=0.058) self.Combo.set(self.ComboList[0]) self.Combo.bind('<<ComboboxSelected>>', self.comboEvent) self.style.configure('InputButton.TButton', font=('宋体', 9)) self.InputButton = Button(self.top, text='浏览', command=self.InputButton_Cmd, style='InputButton.TButton') self.InputButton.place(relx=0.184, rely=0.7, relwidth=0.133, relheight=0.073) self.Haruhi_gif = PhotoImage(data=base64.b64decode(haruhi_gif_data)) self.style.configure('ConvertButton.TButton', font=('宋体', 9)) self.ConvertButton = Button(self.top, image=self.Haruhi_gif, command=self.ConvertButton_Cmd, style='ConvertButton.TButton') self.ConvertButton.place(relx=0.788, rely=0.7, relwidth=0.146, relheight=0.236) self.style.configure('OutputLabel.TLabel', anchor='w', font=('宋体', 9)) self.OutputLabel = Label(self.top, text='保存目录:', style='OutputLabel.TLabel') self.OutputLabel.place(relx=0.066, rely=0.84, relwidth=0.107, relheight=0.05) self.style.configure('InputLabel.TLabel', anchor='w', font=('宋体', 9)) self.InputLabel = Label(self.top, text='输入设置:', style='InputLabel.TLabel') self.InputLabel.place(relx=0.066, rely=0.723, relwidth=0.107, relheight=0.05) menubar = Menu(self.top) filemenu = Menu(menubar, tearoff=0) # tearoff意为下拉 menubar.add_cascade(label='帮助', menu=filemenu) filemenu.add_command(label='视频教程', command=self.open_help_url) filemenu.add_command(label='检查更新', command=self.check_for_update) self.top.config(menu=menubar)
def initUI(self): self.parent.title("Досвидание") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) quitButton = Button(self, text="Закрыть окно", command=self.quit) quitButton.place(x=10, y=50) startButton = Button(self, text="Запустить бота", command=self.quit) startButton.place(x=10, y=80)
def initialize_video_selection_ui(self): # Initialize logo picture logo = Label(self, image=self.logo_image) logo.image = self.logo_image logo.place(y=125, x=200, anchor=tk.CENTER) # Initialize settings button settings_button = Button(self, command=self.open_settings, image=self.settings_icon) settings_button.place(y=275, x=25, anchor=tk.CENTER) # Initialize select video button select_video_button = Button(self, text="Select Video") select_video_button.config(command=partial(self.select_video, [logo, select_video_button, settings_button], [select_video_button, settings_button])) select_video_button.place(y=200, x=200, anchor=tk.CENTER)
def initUI(self): #Apply a theme for our widgets (clam, default, alt, classic) self.style = Style() self.style.theme_use("default") self.master.title("Quit button") self.pack(fill=BOTH, expand=1) #Create instance of button widget, parent is frame container #Provide label and command quitButton = Button(self, text="Quit", command=self.quit) #place geometry to position absolute coordinates quitButton.place(x=50, y=50)
def show_board(self): """ This method creates all the buttons needed to represent a board in the current game instance. """ button_style = Style() button_style.configure("B.TLabel", background='black') button_style.configure("W.TLabel", background='white') button_style.configure("Y.TLabel", background='yellow') button_style.configure("R.TLabel", background='red') button_style.configure("G.TLabel", background='green') param = '' for in1, x in enumerate(self.board.squares): for in2, y in enumerate(x): if (in1 + in2) % 2 == 1: color = 'B' try: param = eval('self.values["' + y.lower()[0:2] + 'b"]') except KeyError: pass else: color = 'W' try: param = eval('self.values["' + y.lower()[0:2] + 'w"]') except KeyError: pass if y[2] == 'k' or y[3] == 'c' or y[4] == 'l': if y[2] == 'k': color = 'R' elif y[3] == 'c': color = 'Y' elif y[4] == 'l': color = 'G' self.board.put_pos_val((in1, in2), self.board.get_pos_val( (in1, in2))[0:2] + ' ') if y.lower()[0:4] != ' ': but = Button(self, style=color + ".TLabel", command=lambda v=(in1, in2): self.pressed(v), image=param, compound=CENTER) else: but = Button(self, style=color + ".TLabel", command=lambda v=(in1, in2): self.pressed(v)) but.place(x=(74 * in2) + 25, y=(74 * in1) + 25, width=68, height=68) self.pack()
def download_screen(): global download_window, just_1butt, just_2butt download_window=Tk() download_window.title("Сравнение") download_window.geometry("300x300") download_window.wm_geometry("+%d+%d" % (x-50, y-50)) download_window.focus_force() window.wm_state('iconic') download_window.protocol("WM_DELETE_WINDOW", on_closing_download_window) just_1butt = Button(download_window, text="Выберите срез", command=download__csv) just_2butt = Button(download_window, text="Загрузить", command=old_bars) just_1butt.place(x=100, y=120) just_2butt.place(x=100, y=150)
def create_buttons(self, button_text=None): """ Method to create and place all buttons for the application """ if button_text is None: button_text = "Run" button = Button(self, text=button_text, command=self.process_k_value) button.place(x=self.get_screen_w() * .75, y=self.get_screen_h() * .80) quit_button = Button(self, text="Quit", command=self.quit) quit_button.place(x=self.get_screen_w() * .80, y=self.get_screen_h() * .80)
def by_departments_screen(): global graph_type, departments_window, combobox graph_type = 2 departments_window = Tk() departments_window.title("По отделам") departments_window.geometry("1200x800") departments_window.wm_geometry("+%d+%d" % (x-250, y-250)) get_departments() combobox = ttk.Combobox(departments_window, values=departments, height=4, width=40) combobox.place(x=25, y=50) save_butt = Button(departments_window, text="Сохранить срез", command=save_departs_csv) save_butt.place(x=300, y=47) paint_butt = Button(departments_window, text="Построить график", command=graph_stat) paint_butt.place(x=410, y=47)
def by_experience_screen(): global graph_type, combobox, experience_window graph_type = 3 experience_window = Tk() experience_window.title("По стажу") experience_window.geometry("1200x800") experience_window.wm_geometry("+%d+%d" % (x-250, y-250)) experience = get_experience() combobox = ttk.Combobox(experience_window, values=experience, width=40) combobox.place(x=25, y=50) save_butt = Button(experience_window, text="Сохранить срез", command=save_departs_csv) save_butt.place(x=300, y=47) paint_butt = Button(experience_window, text="Построить график", command=graph_stat) paint_butt.place(x=410, y=47)
def setup_gui(self): self.parent.title("Stein - Saks - Papir") self.style.theme_use("default") self.pack(fill=BOTH, expand=1) # Label for rapportering label = Label(self.parent, textvariable=self.resultat_label) label.place(x=800, y=50) # Buttons # Disse fyrer av metoden self.arranger_enkeltspill som er # definert i klassen. Denne metoden tar aksjonen til mennesket # som startup, og gjennomfoerer spillet # Samme type oppfoersel for de tre aksjons-knappene rock_button = Button(self, text="Stein", command=lambda: self.arranger_enkeltspill(Action("rock"))) rock_button.place(x=800, y=400) scissors_button = Button(self, text="Saks", command=lambda: self.arranger_enkeltspill(Action("scissor"))) scissors_button.place(x=900, y=400) paper_button = Button(self, text="Papir", command=lambda: self.arranger_enkeltspill(Action("paper"))) paper_button.place(x=1000, y=400) # quit_button avslutter GUI'et naar den trykkes quit_button = Button(self, text="Quit", command=self.quit) quit_button.place(x=1000, y=450) # Embedde en graf i vinduet for aa rapportere fortloepende score self.fig = FigureCanvasTkAgg(pylab.figure(), master=self) self.fig.get_tk_widget().grid(column=0, row=0) self.fig.show()
def setup_gui(self): self.parent.title("Stein - Saks - Papir") self.style.theme_use("default") self.pack(fill=BOTH, expand=1) # Label for rapportering label = Label(self.parent, textvariable=self.resultat_label) label.place(x=800, y=50) # Buttons # Disse fyrer av metoden self.arranger_enkeltspill som er # definert i klassen. Denne metoden tar aksjonen til mennesket # som startup, og gjennomfoerer spillet # Samme type oppfoersel for de tre aksjons-knappene rock_button = Button( self, text="Stein", command=lambda: self.arranger_enkeltspill(Action("rock"))) rock_button.place(x=800, y=400) scissors_button = Button( self, text="Saks", command=lambda: self.arranger_enkeltspill(Action("scissor"))) scissors_button.place(x=900, y=400) paper_button = Button( self, text="Papir", command=lambda: self.arranger_enkeltspill(Action("paper"))) paper_button.place(x=1000, y=400) # quit_button avslutter GUI'et naar den trykkes quit_button = Button(self, text="Quit", command=self.quit) quit_button.place(x=1000, y=450) # Embedde en graf i vinduet for aa rapportere fortloepende score self.fig = FigureCanvasTkAgg(pylab.figure(), master=self) self.fig.get_tk_widget().grid(column=0, row=0) self.fig.show()
def player(self, vid_file: str, m_file: str, nxt_func: object): def get_frame(): ret, frame = vid.read() if ret and self.play: return (ret, cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) else: return (ret, None) def update(): ret, frame = get_frame() if ret and self.play: img = Image.fromarray(frame) photo = ImageTk.PhotoImage(image=img) photo.image = img self.canvas.itemconfig(self.vid_frame, image=photo) self.canvas.image = photo self.parent.after(delay, update) else: # stopping vid_music and starting game music m_player.playing = "" time.sleep(0.01) nxt_func() def skip(): self.play = False self.parent.clear() self.play = True # starting music m_player.playing = m_file vid = cv2.VideoCapture(vid_file) width = vid.get(cv2.CAP_PROP_FRAME_WIDTH) height = vid.get(cv2.CAP_PROP_FRAME_HEIGHT) self.canvas = tk.Canvas(self.parent, width=width, height=height) self.canvas.place(relx=0.5, rely=0.5, anchor=tk.CENTER) self.vid_frame = self.canvas.create_image(0, 0, anchor=tk.NW) # Skip button if vid_file != "project_media\\glitch.mp4": skip_thread = Thread(target=skip) skip = Button(self.parent, text="Skip", command=skip_thread.start, style="skip.TButton") skip.place(relx=0.88, rely=0.04) delay = 5 update()
def by_individual_screen(): global graph_type, combobox, individual_window graph_type = 1 individual_window = Tk() individual_window.title("Индивидуально") individual_window.geometry("1200x800") individual_window.wm_geometry("+%d+%d" % (x-250, y-250)) names = get_names() combobox = ttk.Combobox(individual_window, values=names, width=40) combobox.place(x=25, y=50) # combobox.bind('<<ComboboxSelected>>', lambda event: graph_stat(1, combobox.get(), individual_window)) save_butt = Button(individual_window, text="Сохранить срез", command=save_departs_csv) save_butt.place(x=300, y=47) paint_butt = Button(individual_window, text="Построить график", command=graph_stat) paint_butt.place(x=410, y=47)
class Window(Frame): def __init__(self,master): Frame.__init__(self,master) self.master = master self.initUI() def initUI(self): self.master.title("Parent Window") self.pack(fill=BOTH , expand=1) self.button = Button(self,text="Create New Window", command=self.createWindow) self.button.pack(side="top") self.centerWindow() def centerWindow(self): w = 290 h = 150 sw = self.master.winfo_screenwidth() sh = self.master.winfo_screenheight() x = (sw-w)/2 y = (sh-h)/2 self.master.geometry('%dx%d+%d+%d'%(w,h,x,y)) def createWindow(self): self.parentWindowObject = Toplevel(self) self.parentWindowObject.wm_title("Window") self.label = Label(self.parentWindowObject,text="Hello") self.label.pack(side="top",fill=BOTH) self.button = Button(self.parentWindowObject,text="msg", command =self.msg) self.button.place(x=100,y=100) self.centerWindow() def msg(self): print ("Hello World!")
def initUI(self): self.parent.title("Quit button") self.style = Style() self.style.theme_use("default") # self.pack(fill=BOTH, expand=1) quitButton = Button(self, text="Quit", command=self.quit) quitButton.place(x=200, y=50) buttons_list = [] g=0 c=0 for i in range(1,52): crnt_button = Label(self, text=str(i),background=FF0000) crnt_button.grid(row=g, column=c) buttons_list.append(crnt_button) c += 1 if i%10 ==0: g +=1 c=0
def initUI(self): # Initialize and name Window self.parent.title("Poly Pocket") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) def new_baseline(): return def old_baseline(): return def test(baseline): return def spark_connect(): return def leap_connect(): return def quit(): self.parent.destroy() return welcome = "Welcome to Poly Pocket!" welcome_label = Label(self, text=welcome, font=("Helvetica", 24)) welcome_label.place(x=5, y=5) welcome_label.pack() baseline_button = Button(self, text="New Baseline", command=new_baseline()) recover_baseline_button = Button(self, text="Recover Baseline", command=old_baseline()) test_button = Button(self, text="Conduct Test", command=test(self.baseline)) connect_leap_button = Button(self, text="Establish Leap Connection", command=leap_connect) connect_spark_button = Button(self, text="Establish Spark Connection", command=spark_connect) exit_button = Button(self, text="Quit", command=quit) baseline_button.place(relx=0.5, rely=0.3, anchor=CENTER) recover_baseline_button.place(relx=0.5, rely=0.4, anchor=CENTER) test_button.place(relx=0.5, rely=0.5, anchor=CENTER) connect_leap_button.place(relx=0.5, rely=0.6, anchor=CENTER) connect_spark_button.place(relx=0.5, rely=0.7, anchor=CENTER) exit_button.place(relx=0.5, rely = 0.8, anchor=CENTER)