def session(): wsession = tk.Toplevel(gui) ttk.Label(wsession, text="Session time (in sec): ").pack() stimeinput = ttk.Entry(wsession, width=10) stimeinput.insert(tk.END, str(sessiontime)) stimeinput.pack() ttk.Label(wsession, text="Break time (in sec): ").pack() btimeinput = ttk.Entry(wsession, width=10) btimeinput.insert(tk.END, str(breaktime)) btimeinput.pack() def done(): global sessiontime, stime_min, stime_sec, onesec, breaktime, btime_min, btime_sec sessiontime = int(stimeinput.get()) stime_min = sessiontime // 60 stime_sec = sessiontime % 60 onesec = 360 / sessiontime breaktime = int(btimeinput.get()) btime_min = breaktime // 60 btime_sec = breaktime % 60 wsetting() ttk.Button(wsession, text="Ok!", command=done).pack() ttk.Label(wsession, text="_________________________________").pack() btn1 = AskButtons(wsession, "Advanced settings?", 0) #btn2 = AskButtons(wsession, "Unlimited session time?", 1) # Don't enable this! btn3 = AskButtons(wsession, "Disable breaktime?", 2)
def insertb(): winput = tk.Toplevel(wblocklist) winput.title("Add program") entry = ttk.Entry(winput, width=10) entry.pack() def getinput(): global sitelist sitelist.insert(tk.END, str(entry.get())) global sites sites.append(str(entry.get())) wsetting() winput.destroy() button = ttk.Button(winput, text="Add", command=getinput) button.pack()
def add_text_widget(window, width=10, column=0, row=0): text = tk.StringVar() text_entered = ttk.Entry(window, width=width, textvariable=text) text_entered.grid(column=column, row=row) text_entered.focus() return text_entered
methodlabel = ttk.Label(root, text = "Select Decryption method", justify = tk.LEFT, padding = (20,0,0,0)) p = ttk.Radiobutton(root, text = "Password", variable = method, value = 1) pk = ttk.Radiobutton(root, text = "Private Key", variable = method, value = 2) password = ttk.Entry(root, show="*") pkfilebox = ttk.Entry(root, state='disabled') method.set(1) def load_file(): fname = tkinter.filedialog.askopenfilename() if fname: try: pkfilebox.config(state='normal') pkfilebox.delete(0, 'end') pkfilebox.insert(0, fname) pkfilebox.config(state='readonly') except: tkinter.messagebox.showwarning("Open Key File", "Failed to read file\n'%s'" % fname)
def __init__(self, master): # formating window to have meaningful label and nice colours master.title('Silk Road Historic Feature Data Collection') master.configure(background = '#00000') # add in some window-universal styling self.style = ttk.Style() self.style.configure('TFrame', background = '#7387ed') self.style.configure('TButton', background = '#7387ed') self.style.configure('TLabelFrame', background = '#7387ed', font=('Arial', 12)) self.style.configure('TLabel', background = '#7387ed', font = ('Arial', 11)) self.style.configure('Header.TLabel', font = ('Arial', 18, 'bold')) # creating header frame and using pack geometry master to place at # top of window. This frame thanks user for contributing data. self.frame_header = ttk.Frame(master) self.frame_header.pack() ttk.Label(self.frame_header, text = "Thank you for sharing information about the Silk Road!", font = ('Arial', 14), background = '#7387ed').pack(pady=5) # creating a second frame in window - this time using the LabelFrame # constructor, so that the Location data being collected is made # distinct from other data types to avoid confusion about state (i.e., # want location and not current status). Using pack geometry manager to # add frame under header. self.frame_loc = ttk.Labelframe(master, text="Location of Historic Feature") self.frame_loc.pack() # creating labels for each of the location inputs ttk.Label(self.frame_loc, text = "City:").grid(row = 0, column = 0, pady = 3, sticky = 'sw') ttk.Label(self.frame_loc, text = "State:").grid(row = 2, column = 0, pady = 3, sticky = 'sw') ttk.Label(self.frame_loc, text = "Country:").grid(row = 4, column = 0, pady = 3, sticky = 'sw') # creating Entry widgets for user input of location info self.entry_city = ttk.Entry(self.frame_loc, width = 50, font = ('Arial', 11)) self.entry_state = ttk.Entry(self.frame_loc, width = 50, font = ('Arial', 11)) self.entry_country = ttk.Entry(self.frame_loc, width = 50, font =('Arial', 11)) # using grid geometry manager on entry widgets self.entry_city.grid(row = 1, column = 0) self.entry_state.grid(row = 3, column = 0) self.entry_country.grid(row = 5, column = 0) # creating another LabelFrame for Feature Detail section. Using pack # geometry mananger to add it under the Location frame. self.frame_details = ttk.Labelframe(master, text = "Feature Details") self.frame_details.pack() # creating Label widgets for each input ttk.Label(self.frame_details, text = "Name of Feature:").grid(row=0, column = 0, pady = 3, sticky = 'sw') ttk.Label(self.frame_details, text = "Type of Feature:").grid(row=2, column=0, pady = 3, sticky = 'sw') # creating widgets for feature details; name will be an Entry widget and # type will be a text widget to allow multi-line entry self.entry_name = ttk.Entry(self.frame_details, width = 60, font = ('Arial', 11)) self.text_type = Text(self.frame_details, width = 60, height = 10, font = ('Arial', 11)) # using grid geometry manager on feature detail widgets self.entry_name.grid(row = 1, column = 0) self.text_type.grid(row = 3, column = 0) # create buttons for Submit and Clear options. Submit sends data and # then the data is cleared from the fields ready for next entry. Clear # deletes all information from all fields. ttk.Button(self.frame_details, text = "Submit", command = self.submit).grid(row = 4, column = 0, pady=5) ttk.Button(self.frame_details, text = "Clear", command = self.clear).grid(row = 4, column = 1, pady=5)
def calculate(*args): try: value = float(feet.get()) meters.set((0.3048 * value * 10000.0 + 0.5) / 10000.0) except ValueError: pass root = Tk() root.title("Feet to Meters") mainframe = ttk.Frame(root, padding="3 3 12 12") mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) feet = StringVar() meters = StringVar() feet_entry = ttk.Entry(mainframe, width=7, textvariable=feet) feet_entry.grid(column=2, row=1, sticky=(W, E)) ttk.Label(mainframe, textvariable=meters).grid(column=2, row=2, sticky=(W, E)) ttk.Button(mainframe, text="Calculate", command=calculate).grid(column=3, row=3, sticky=W) ttk.Label(mainframe, text="feet").grid(column=3, row=1, sticky=W) ttk.Label(mainframe, text="is equivalent to").grid(column=1, row=2, sticky=E) ttk.Label(mainframe, text="meters").grid(column=3, row=2, sticky=W) for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5) feet_entry.focus() root.bind('<Return>', calculate) root.mainloop()
def __init__(self, parent, title=None): Tk.Frame.__init__(self, parent) self.songURL = "EMPTY" self.songLabels = [] # list for names of songs self.webcamLbl = ttk.Label() # webcam image widget label self.photoTaken = False self.webcam = cv2.VideoCapture(0) self.updateB = True # bool to start and stop webcam update self.lastURL = "EMPTY" self.speed = 10 # milliseconds between UI refresh self.songs = [] self.songCounter = 0 self.parent = parent self.emotion = "" self.shutter = 0 self.curated = True if title == None: title = "tk_vlc" self.parent.title(title) self.topMaster = ttk.Frame(self.parent) self.topPanel = ttk.Frame(self.topMaster) self.topPanelR = ttk.Frame(self.topMaster) #self.songName = ttk.Label(self.topPanel, text="Song: N/A") self.songName = ttk.Label(self.topPanel, text="Song: N/A") self.artistName = ttk.Label(self.topPanel, text="Artist: N/A") self.emotionLabel = ttk.Label(self.topPanel, text="Emotion: N/A") self.webCamButton = ttk.Button(self.topPanelR, text="Webcam Active", command=self.activateWebcam, width=15) self.shutter = ttk.Button(self.topPanelR, text="Take Photo", command=self.takethephoto, width=15) photostripButton = ttk.Button(self.topPanelR, text="Photostrip", command=self.browseFile, width=15) self.songName.grid(row=0, column=0, sticky=Tk.W) self.artistName.grid(row=1, column=0, sticky=Tk.W) self.emotionLabel.grid(row=2, column=0, sticky=Tk.W) photostripButton.grid(row=1, column=1, sticky=Tk.E) self.shutter.grid(row=0, column=0, rowspan=2, sticky=Tk.E, ipady=13) self.webCamButton.grid(row=0, column=1, sticky=Tk.E) self.topPanel.pack(fill=Tk.BOTH, side=Tk.LEFT) self.topPanelR.pack(fill=Tk.BOTH, side=Tk.RIGHT) self.topMaster.pack(fill=Tk.BOTH, side=Tk.TOP) # The second panel holds controls self.player = None self.videopanel = ttk.Frame(self.parent) image = im.open("artwork/default.jpg") photo = image imgtk = imTk.PhotoImage(image=image) self.webcamLbl = ttk.Label(self.videopanel, image=imgtk, text="Stream") self.webcamLbl.image = imgtk self.webcamLbl.pack(side=Tk.BOTTOM) self.videopanel.pack(fill=Tk.BOTH, expand=1) self.videopanel.pack_propagate(False) self.videopanel["width"] = 650 self.videopanel["height"] = 500 ctrlpanel = ttk.Frame(self.parent) pause = ttk.Button(ctrlpanel, text="Pause", command=self.OnPause) play = ttk.Button(ctrlpanel, text="Play", command=self.OnPlay) stop = ttk.Button(ctrlpanel, text="Stop", command=self.OnStop) volume = ttk.Label(ctrlpanel, text="Volume") self.nextButton = ttk.Button(ctrlpanel, text="Next", command=self.OnNext) self.prevButton = ttk.Button(ctrlpanel, text="Previous", command=self.OnPrev) self.prevButton.pack(side=Tk.LEFT) pause.pack(side=Tk.LEFT) play.pack(side=Tk.LEFT) stop.pack(side=Tk.LEFT) self.nextButton.pack(side=Tk.LEFT) self.nextButton["state"] = "disabled" self.prevButton["state"] = "disabled" volume.pack(side=Tk.LEFT) self.volume_var = Tk.IntVar() self.volslider = Tk.Scale(ctrlpanel, variable=self.volume_var, command=self.volume_sel, from_=0, to=100, orient=Tk.HORIZONTAL, length=100) self.volslider.pack(side=Tk.LEFT) self.volume_var.set(50) ctrlpanel.pack(side=Tk.BOTTOM) ctrlpanel2 = ttk.Frame(self.parent) self.scale_var = Tk.DoubleVar() self.timeslider_last_val = "" self.timeslider = Tk.Scale(ctrlpanel2, variable=self.scale_var, command=self.scale_sel, from_=0, to=1000, orient=Tk.HORIZONTAL, length=500) self.timeslider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) self.timeslider_last_update = time.time() ctrlpanel2.pack(side=Tk.BOTTOM, fill=Tk.X) ctrlpanel3 = ttk.Frame(self.parent) self.curated = Tk.IntVar() self.curateCheck = ttk.Checkbutton(ctrlpanel3, text="Curate", variable=self.curated) self.curated.set(1) self.curateCheck.pack(side=Tk.RIGHT) self.message = ttk.Label(ctrlpanel3, text="Status: Ready to take photo.") self.message.pack(side=Tk.LEFT) self.share = ttk.Button(ctrlpanel3, text="Share", command=self.share) self.share.pack(side=Tk.RIGHT) self.inputText = ttk.Entry(ctrlpanel3, width=15) self.inputText.pack(side=Tk.RIGHT) self.instruction = ttk.Label(ctrlpanel3, text="Your name: ") self.instruction.pack(side=Tk.RIGHT) ctrlpanel3.pack(fill=Tk.BOTH, side=Tk.TOP) # VLC player controls self.Instance = vlc.Instance() self.player = self.Instance.media_player_new() #self.player.audio_set_volume(100) self.timer = ttkTimer(self.OnTimer, 1.0) self.timer.start() self.parent.update()
except ValueError: try: messagebox.showerror("Error", "Sadece sayı girinizi") except: ttk.MessageBox.showerror("Error", "Sadece sayı giriniz") sys.exit(0) label1 = ttk.Label(root,text='Ne kadar süre içinde kapatılsın', font=top_label_font) label1.grid(row=0,column=0,pady=10,padx=10) time_frame = ttk.Frame(root) time_frame.grid(row=2,column=0,padx=10,pady=10) hours = ttk.Entry(time_frame, font=time_font,width=entry_width) # hours.insert(0, '00') hours.grid(row=0,column=1) label2 = ttk.Label(time_frame,text=':', font=time_font) label2.grid(row=0,column=2) minutes = ttk.Entry(time_frame, font=time_font,width=entry_width) # minutes.insert(0, '00') minutes.grid(row=0,column=3) label3 = ttk.Label(time_frame,text=':', font=time_font) label3.grid(row=0,column=4) seconds = ttk.Entry(time_frame, font=time_font,width=entry_width) # seconds.insert(0, '00')
fPH71Xeef/kFyB93/sln4EP2Ebjegg31B5+CEDLUIH4PVqiQhOABqKFCF6qn 34cHcfjffCQaFOJtGaZYkIkUuljQigXK+CKCE3po40A0trgjjDru+EGPI/6I Y4co7kikkAMBmaSNSzL5gZNSDjkghkXaaGIBHjwpY4gThJeljFt2WSWYMQpZ 5pguUnClehS4tuMEDARQgH8FBMBBBExGwIGdAxywXAUBKHCZkAIoEEAFp33W QGl47ZgBAwZEwKigE1SQgAUCUDCXiwtQIIAFCTQwgaCrZeCABAzIleIGHDD/ oIAHGUznmXABGMABT4xpmBYBHGgAKGq1ZbppThgAG8EEAW61KwYMSOBAApdy pNp/BkhAAQLcEqCTt+ACJW645I5rLrgEeOsTBtwiQIEElRZg61sTNBBethSw CwEA/Pbr778ABywwABBAgAAG7xpAq6mGUUTdAPZ6YIACsRKAAbvtZqzxxhxn jDG3ybbKFHf36ZVYpuE5oIGhHMTqcqswvyxzzDS/HDMHEiiggQMLDxCZXh8k BnEBCQTggAUGGKCB0ktr0PTTTEfttNRQT22ABR4EkEABDXgnGUEn31ZABglE EEAAWaeN9tpqt832221HEEECW6M3wc+Hga3SBgtMODBABw00UEEBgxdO+OGG J4744oZzXUEDHQxwN7F5G7QRdXxPoPkAnHfu+eeghw665n1vIKhJBQUEADs=""") style = ttk.Style() style.element_create("RoundedFrame", "image", "frameBorder", ("focus", "frameFocusBorder"), border=16, sticky="nsew") style.layout("RoundedFrame", [("RoundedFrame", {"sticky": "nsew"})]) style.configure("TEntry", borderwidth=0) frame = ttk.Frame(style="RoundedFrame", padding=10) frame.pack(fill='x') frame2 = ttk.Frame(style="RoundedFrame", padding=10) frame2.pack(fill='both', expand=1) entry = ttk.Entry(frame) entry.pack(fill='x') entry.bind("<FocusIn>", lambda evt: frame.state(["focus"])) entry.bind("<FocusOut>", lambda evt: frame.state(["!focus"])) text = tk.Text(frame2, borderwidth=0, bg="white", highlightthickness=0) text.pack(fill='both', expand=1) text.bind("<FocusIn>", lambda evt: frame2.state(["focus"])) text.bind("<FocusOut>", lambda evt: frame2.state(["!focus"])) root.mainloop()
def popupmsg(): global image, lab_5_data, lab_6_data, lab_7_data, error_flag_1, error_flag_2, error_flag_3, butter_width, butter_order, butter_a, popup_true butter_width = "" butter_order = "" butter_a = "" #fetch_details() fetches the user filled values in entry widgets once the user clicks 'ok' button def fetch_details(): global image, lab_5_data, lab_6_data, lab_7_data, error_flag_1, error_flag_2, error_flag_3, butter_width, butter_order, butter_a, popup_true lab_5_data.set("") lab_6_data.set("") lab_7_data.set("") error_flag_1 = 0 error_flag_2 = 0 error_flag_3 = 0 try: #the below try-catch are used for validation of user input filled in the entry widgets butter_width = int( e1.get() ) #get() function is used to retrieve data filled in the entry widget except ValueError: #ValueError occurs if the typecasting to int was not successful lab_5_data.set("Plese enter integer") error_flag_1 = 1 try: butter_order = int(e2.get()) except ValueError: lab_6_data.set("Plese enter integer") error_flag_2 = 1 try: butter_a = float(e3.get()) #dc_amplification value can lie between 0 an 1 inclusive only. if ((butter_a < 0) or (butter_a > 1)): lab_7_data.set("value between 0 and 1") error_flag_3 = 1 except ValueError: lab_7_data.set("Plese enter float") error_flag_3 = 1 #if there was erroneous input then destroy the popup and ask input again if ((error_flag_1 == 1) or (error_flag_2 == 1) or (error_flag_3 == 1)): popup.destroy() popupmsg() else: popup_true = 1 #no erroneous input from user var3.set(popup_true) popup = Tk.Tk() #defining a popup window over my parent window popup.wm_title("Please enter details") #callback3() is used to destroy popup window and return control to main window def callback3(*args): if (popup_true == 1): popup.destroy() popup_return() ### #below portion defines the popup structure label1 = ttk.Label(popup, text="Width: ").grid(row=0) label2 = ttk.Label(popup, text="Order: ").grid(row=2) label3 = ttk.Label(popup, text="DC_amplification_factor(a): ").grid(row=4) e1 = ttk.Entry(popup) e2 = ttk.Entry(popup) e3 = ttk.Entry(popup) e1.grid(row=0, column=1) e2.grid(row=2, column=1) e3.grid(row=4, column=1) #if error_flag_x==0 then that entry x was not erroneous. thus retain the data filled in it. #user doesn't need to retype the data if he filled that entry correctly. if (error_flag_1 == 0): e1.insert(0, str(butter_width)) #insert(index, string) if (error_flag_2 == 0): e2.insert(0, str(butter_order)) #insert(index, string) if (error_flag_3 == 0): e3.insert(0, str(butter_a)) #insert(index, string) label4 = ttk.Label(popup, text=" ").grid(row=0, column=2) label5 = ttk.Label(popup, text=lab_5_data.get()).grid(row=1, column=1) label6 = ttk.Label(popup, text=lab_6_data.get()).grid(row=3, column=1) label7 = ttk.Label(popup, text=lab_7_data.get()).grid(row=5, column=1) B1 = ttk.Button(popup, text="Okay", command=fetch_details) B1.grid(row=6, column=1) ### var3 = Tk.StringVar() #defining a callback for popup_true. #callback3() function will be called on each update of popup_true variable. var3.trace("w", callback3) popup.mainloop()