def test_menu(self): items = ('a', 'b', 'c') default = 'a' optmenu = ttk.OptionMenu(None, self.textvar, default, *items) found_default = False for i in range(len(items)): value = optmenu['menu'].entrycget(i, 'value') self.assertEqual(value, items[i]) if value == default: found_default = True self.assertTrue(found_default) optmenu.destroy() # default shouldn't be in menu if it is not part of values default = 'd' optmenu = ttk.OptionMenu(None, self.textvar, default, *items) curr = None i = 0 while True: last, curr = curr, optmenu['menu'].entryconfigure(i, 'value') if last == curr: # no more menu entries break self.assertFalse(curr == default) i += 1 self.assertEqual(i, len(items)) # check that variable is updated correctly optmenu.pack() optmenu.wait_visibility() optmenu['menu'].invoke(0) self.assertEqual(optmenu._variable.get(), items[0]) # changing to an invalid index shouldn't change the variable self.assertRaises(Tkinter.TclError, optmenu['menu'].invoke, -1) self.assertEqual(optmenu._variable.get(), items[0]) optmenu.destroy() # specifying a callback success = [] def cb_test(item): self.assertEqual(item, items[1]) success.append(True) optmenu = ttk.OptionMenu(None, self.textvar, 'a', command=cb_test, *items) optmenu['menu'].invoke(1) if not success: self.fail("Menu callback not invoked") optmenu.destroy()
def frame1(self): self.frame1 = ttk.LabelFrame(self.master, text = "Parameters", borderwidth = 2, relief = "groove") self.frame1.place(bordermode = "outside", relwidth = 0.99, relheight = 0.21, relx = 0, x = 5, y = 5, anchor = "nw") self.frame1.first_run = True # function function_label = ttk.Label(self.frame1, text = "Function") function_option_menu = ttk.OptionMenu(self.frame1, self.function, self.function.get(), *sorted(self.FUNCOPT)) # max_iter max_iter_label = ttk.Label(self.frame1, text = "Maximum number of iterations") max_iter_spinbox = Spinbox(self.frame1, from_ = 2, to_ = 9999, increment = 1, textvariable = self.max_iter, width = 6, justify = "right", takefocus = True) # fps fps_label = ttk.Label(self.frame1, text = "Delay between frames (ms)") fps_spinbox = Spinbox(self.frame1, from_ = 1, to_ = 1000, increment = 1, textvariable = self.interval, width = 6, justify = "right", takefocus = True) # seed seed_button = ttk.Checkbutton(self.frame1, text = "Fix seed", variable = self.fix_seed, takefocus = False) seed_spinbox = Spinbox(self.frame1, from_ = 0, to_ = self.MAX_SEED, increment = 1, textvariable = self.seed, width = 6, justify = "right", takefocus = True) # solver solver_label = ttk.Label(self.frame1, text = "Solver") solver_option_menu = ttk.OptionMenu(self.frame1, self.solver_name, self.solver_name.get(), *(self.EAOPT + self.MCOPT), command = self.select_widget) # constrain constrain_button = ttk.Checkbutton(self.frame1, text = "Constrain", variable = self.constrain, takefocus = False) # Layout function_label.place(relx = 0., x = 5, y = 5, anchor = "nw") function_option_menu.place(relx = 0., x = 75, y = 3, anchor = "nw") max_iter_label.place(relx = 0., x = 5, y = 30, anchor = "nw") max_iter_spinbox.place(width = 80, relx = 0., x = 220, y = 30, anchor = "nw") fps_label.place(relx = 0., x = 5, y = 55, anchor = "nw") fps_spinbox.place(width = 80, relx = 0., x = 220, y = 55, anchor = "nw") seed_button.place(relx = 0., x = 5, y = 80, anchor = "nw") seed_spinbox.place(width = 80, relx = 0., x = 220, y = 80, anchor = "nw") solver_label.place(relx = 0.35, x = 0, y = 5, anchor = "nw") solver_option_menu.place(relx = 0.35, x = 50, y = 3, anchor = "nw") constrain_button.place(relx = 0.35, x = 0, y = 80, anchor = "nw")
def backup_time(*args): def destroy(): if any(True for res in args if "move" == res): move_backup_time_text.set(backuptime.get() + " " + ampm.get()) toplevel_t.destroy() else: backup_time_text.set(backuptime.get() + " " + ampm.get()) toplevel_t.destroy() global toplevel_t # to destroy any toplevel previously raised if toplevel_t: toplevel_t.destroy() toplevel_t = Toplevel() #t.transient(root) toplevel_t.wm_title("Window") mainframe = ttk.Frame(toplevel_t, padding="1 1 1 1") mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) if any(True for res in args if "move" == res): ttk.Label(mainframe, text="Move Backup Times").grid(column=1, row=1, sticky=W, padx=10, pady=1) else: ttk.Label(mainframe, text="Backup Times").grid(column=1, row=1, sticky=W, padx=10, pady=1) backuptime = StringVar() ampm = StringVar() ttk.OptionMenu(mainframe, backuptime, "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12").grid(column=2, row=1, sticky=W, padx=0, pady=1) ttk.OptionMenu(mainframe, ampm, "PM", "AM").grid(column=3, row=1, sticky=W, padx=0, pady=1) ttk.Button(mainframe, text="OK", command=destroy).grid(column=4, row=1, sticky=W, padx=10, pady=1)
def test_menu(self): items = ('a', 'b', 'c') default = 'a' optmenu = ttk.OptionMenu(None, self.textvar, default, *items) found_default = False for i in range(len(items)): value = optmenu['menu'].entrycget(i, 'value') self.assertEqual(value, items[i]) if value == default: found_default = True self.assertTrue(found_default) optmenu.destroy() default = 'd' optmenu = ttk.OptionMenu(None, self.textvar, default, *items) curr = None i = 0 while True: last, curr = curr, optmenu['menu'].entryconfigure(i, 'value') if last == curr: break self.assertNotEqual(curr, default) i += 1 self.assertEqual(i, len(items)) optmenu.pack() optmenu.wait_visibility() optmenu['menu'].invoke(0) self.assertEqual(optmenu._variable.get(), items[0]) self.assertRaises(Tkinter.TclError, optmenu['menu'].invoke, -1) self.assertEqual(optmenu._variable.get(), items[0]) optmenu.destroy() success = [] def cb_test(item): self.assertEqual(item, items[1]) success.append(True) optmenu = ttk.OptionMenu(None, self.textvar, 'a', command=cb_test, *items) optmenu['menu'].invoke(1) if not success: self.fail('Menu callback not invoked') optmenu.destroy() return
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) tkvar = tk.StringVar() label = tk.Label(self, text=dict_questions["question_pstart"], font=dict_features["large_font"]).place(relx=0.1, rely=0.1) popupMenu = ttk.OptionMenu(self, tkvar, "Options", *dict_answ_choices["choice_startpg"]).place( relx=0.1, rely=0.8) self.button0 = ttk.Button( self, text=dict_bttns['next_bttn'], command=lambda: controller.show_frame(PageOne)).place(relx=0.8, rely=0.8) def change_dropdown(*args): if (tkvar.get() == 'Retrieve'): retrieve_db() elif (tkvar.get() == 'Additional information'): info_on_metrics() # link function to change dropdown tkvar.trace('w', change_dropdown)
def __init__(self): self.frame = ttk.LabelFrame(window, text='Conectar') self.frame.pack(expand="yes", fill="both", padx=10, pady=10) self.inFrameTop = ttk.Frame(self.frame) self.inFrameBottom = ttk.Frame(self.frame) self.inFrameTop.pack() self.inFrameBottom.pack() self.connection = serial.Serial() self.ports = ['No hay puertos'] self.selectedPort = tk.StringVar() self.portsLabel = ttk.Label(self.inFrameTop, text='Puerto: ') self.portsLabel.pack(side=tk.LEFT) self.select = ttk.OptionMenu(self.inFrameTop, self.selectedPort, *self.ports) self.select.pack(side=tk.LEFT) self.reloadButton = ttk.Button(self.inFrameBottom, text='Recargar puertos', command=self.loadPorts) self.reloadButton.pack(side=tk.LEFT) self.connectButton = ttk.Button(self.inFrameBottom, text='Conectar', command=self.connect) self.connectButton.pack(side=tk.LEFT) self.disconnectButton = ttk.Button(self.inFrameBottom, text='Desconectar', command=self.disconnect) self.disconnectButton.pack(side=tk.LEFT) self.loadPorts() self.onPortChanged = Event()
def SetFilters(self): """ ############################################################ This Routine will make sure that the filters get contructed properly... ############################################################ """ try: for Element in self.OptionMenuList: Element.destroy() except: pass self.OptionMenuList = [] self.Variables = [] self.ImagingTypeList = [] self.DefaultList = [ '', 'All Types', 'All Wavelength', 'All Powers', 'All Gratings', 'All Objectifs', 'All Durations', 'All N. Acquisis.', 'All Sample IDs', 'All Samples', 'All Substrates', 'All Sam. Info', 'All Sub. Info' ] if not self.Condensensed == None: for i in range(1, len(self.Condensensed)): #create the variable for this drop down self.Variables.append(StringVar()) #create the two lists self.ImagingTypeList.append([self.DefaultList[i]]) for j in range(0, len(self.Condensensed[i])): self.ImagingTypeList[-1].append(self.Condensensed[i][j][0]) #Create the two elements self.OptionMenuList.append( ttk.OptionMenu(self.FilterFrame, self.Variables[-1], self.ImagingTypeList[-1][0], *self.ImagingTypeList[-1], command=self.Filter)) #set it self.OptionMenuList[-1].grid(column=(i - 1) % 6, row=(i - 1) / 6, sticky='ew') for i in range(6): self.FilterFrame.grid_columnconfigure(i, weight=1)
def test_initialization(self): self.assertRaises(Tkinter.TclError, ttk.OptionMenu, None, self.textvar, invalid='thing') optmenu = ttk.OptionMenu(None, self.textvar, 'b', 'a', 'b') self.assertEqual(optmenu._variable.get(), 'b') self.assertTrue(optmenu['menu']) self.assertTrue(optmenu['textvariable']) optmenu.destroy() return
def add_optionmenu(self, optionmenu_variable): optionmenu = ttk.OptionMenu( self, optionmenu_variable, self.optionmenu_choices[0], *self.optionmenu_choices ) optionmenu.place( x = self.label_x + self.horizontal_separation, y = self.label_y )
def test_widget_destroy(self): var = Tkinter.StringVar() optmenu = ttk.OptionMenu(None, var) name = var._name optmenu.update_idletasks() optmenu.destroy() self.failUnlessEqual(optmenu.tk.globalgetvar(name), var.get()) del var self.failUnlessRaises(Tkinter.TclError, optmenu.tk.globalgetvar, name)
def test_widget_destroy(self): var = tkinter.StringVar(self.root) optmenu = ttk.OptionMenu(self.root, var) name = var._name optmenu.update_idletasks() optmenu.destroy() self.assertEqual(optmenu.tk.globalgetvar(name), var.get()) del var self.assertRaises(tkinter.TclError, optmenu.tk.globalgetvar, name)
def add_detection_method_optionmenu(self): self.detection_method = Tkinter.StringVar(self.root) available_detection_methods = [ 'Modularity', 'RBConfiguration', 'RBER', 'CPM', 'Significance', 'Surprise' ] self.detection_method_optionmenu = ttk.OptionMenu( self, self.detection_method, available_detection_methods[0], *available_detection_methods) self.detection_method_optionmenu.place( x=self.detection_method_label_x + 115, y=self.detection_method_label_y)
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.controller = controller page_title = tk.Label(self, text="Edit Story Page", font=LARGE_FONT) page_title.pack(side="top", pady=15) textEditFrame = tk.Frame(self) textEditFrame.pack(fill=tk.BOTH, expand=1, padx=30, pady=30) scrollBar = ttk.Scrollbar(textEditFrame) scrollBar.pack(side="right", fill="y") self.aboutRoom = tk.Text(textEditFrame, height=10, yscrollcommand=scrollBar.set) self.aboutRoom.insert(tk.END, "Please select a script to view and edit it.") self.aboutRoom.pack(fill=tk.BOTH, expand=1) scrollBar.config(command=self.aboutRoom.yview) commandWrapper = tk.Frame(self) commandWrapper.pack() self.storyFiles = tk.StringVar() self.storyFiles.set(None) files = self.controller.story_dict().keys() self.storyDropDown = ttk.OptionMenu(commandWrapper, self.storyFiles, self.storyFiles.get(), *files) self.storyDropDown.pack(side='left', padx=5, pady=5) openStoryButt = ttk.Button( commandWrapper, text="Open Scene", command=lambda: self.open_files(self.storyFiles.get())) openStoryButt.pack(side='left', padx=5, pady=5) saveSceneButt = ttk.Button(commandWrapper, text="Save Scene", command=self.save_script) saveSceneButt.pack(side='left', padx=5, pady=5) """ Status Bar """ status_text = "Edit the screenplay for each scene" self.statusBar = tk.Label(self, bd=1, text=status_text, relief="sunken", anchor="e") # Status bar is copied for each page! TODO: Add it once for all pages! self.statusBar.pack(side="bottom", fill="x") """ Story Edit Update Function """ self.controller.currentGame.trace("w", callback=self.edit_update)
def makeLocaleSettings(self, root): localeFrame = ttk.LabelFrame(root, text = Local('Localization')) localeFrame.pack(side = 'top', fill = 'x', padx = 3, pady = 3) langFrame = ttk.Frame(localeFrame) langFrame.pack(side = 'top', fill = 'x') ttk.Label(langFrame, text = Local('Language:')).pack(side = 'left', padx = 3, pady = 3) def changeLang(x): setLocale(x) self.reload = True if self.protScanTask is not None: self.root.after_cancel(self.protScanTask) self.root.destroy() ttk.OptionMenu(langFrame, StringVar(), getCurrentLocale(), *getLocales(), command = changeLang).pack(side = 'left', padx = 3, pady = 3)
def __init__(self, base): # Base Frame Configuration self.base = base base.title("PcapXray") Label(base, text="PcapXray Tool - A LAN Network Analyzer") # Style Configuration style = ttk.Style() style.configure("BW.TLabel", foreground="black") style.configure("BW.TEntry", foreground="black") # 1st Frame - Initial Frame InitFrame = ttk.Frame(base, width=50, padding="10 10 10 10",relief= GROOVE) InitFrame.grid(column=10, row=10, sticky=(N, W, E, S)) InitFrame.columnconfigure(10, weight=1) InitFrame.rowconfigure(10, weight=1) # Pcap File Entry self.pcap_file = StringVar() ttk.Label(InitFrame, text="Enter pcap file path: ",style="BW.TLabel").grid(column=0, row=0, sticky="W") ttk.Entry(InitFrame, width=30, textvariable=self.pcap_file, style="BW.TEntry").grid(column=1, row=0, sticky="W, E") self.progressbar = ttk.Progressbar(InitFrame, orient="horizontal", length=200,value=0, maximum=200, mode="indeterminate") ttk.Button(InitFrame, text="Analyze!", command=self.pcap_analyse).grid(column=2, row=0, padx=10, pady=10,sticky="E") self.progressbar.grid(column=3, row=0, padx=10, pady=10, sticky="E") # Second Frame with Options SecondFrame = ttk.Frame(base, width=50, padding="10 10 10 10",relief= GROOVE) SecondFrame.grid(column=10, row=20, sticky=(N, W, E, S)) SecondFrame.columnconfigure(10, weight=1) SecondFrame.rowconfigure(10, weight=1) ttk.Label(SecondFrame, text="Options: ", style="BW.TLabel").grid(column=0, row=10, sticky="W") self.option = StringVar() self.options = {'All','HTTP','HTTPS','Tor','Malicious'} #self.option.set('Tor') ttk.OptionMenu(SecondFrame,self.option,"Select",*self.options).grid(column=1, row=10,sticky="W, E") # Third Frame with Results and Descriptioms self.ThirdFrame = ttk.Frame(base, width=100, height=100, padding="10 10 10 10",relief= GROOVE) description = """It is a tool aimed to simplyfy the network analysis and speed the process of analysing the network traffic.\nThis prototype aims to accomplish 4 important modules, \n 1. Web Traffic\n 2. Tor Traffic \n 3. Malicious Traffic \n 4. Device/Traffic Details\n\nPlease contact me @ [email protected] for any bugs or problems ! """ self.label = ttk.Label(self.ThirdFrame, text="Description: \nPcapXray tools is an aid for Network Forensics or Any Network Analysis!\n"+description, style="BW.TLabel") self.label.grid(column=10, row=10,sticky="W") self.xscrollbar = Scrollbar(self.ThirdFrame, orient=HORIZONTAL) self.xscrollbar.grid(row=100, column=0, sticky=E + W) self.yscrollbar = Scrollbar(self.ThirdFrame, orient=VERTICAL) self.yscrollbar.grid(row=0, column=100, sticky=N + S) self.ThirdFrame.grid(column=10, row=30, sticky=(N, W, E, S)) self.ThirdFrame.columnconfigure(0, weight=1) self.ThirdFrame.rowconfigure(0, weight=1) self.name_servers = ""
def test_unique_radiobuttons(self): # check that radiobuttons are unique across instances (bpo25684) items = ('a', 'b', 'c') default = 'a' optmenu = ttk.OptionMenu(self.root, self.textvar, default, *items) textvar2 = tkinter.StringVar(self.root) optmenu2 = ttk.OptionMenu(self.root, textvar2, default, *items) optmenu.pack() optmenu.wait_visibility() optmenu2.pack() optmenu2.wait_visibility() optmenu['menu'].invoke(1) optmenu2['menu'].invoke(2) optmenu_stringvar_name = optmenu['menu'].entrycget(0, 'variable') optmenu2_stringvar_name = optmenu2['menu'].entrycget(0, 'variable') self.assertNotEqual(optmenu_stringvar_name, optmenu2_stringvar_name) self.assertEqual(self.root.tk.globalgetvar(optmenu_stringvar_name), items[1]) self.assertEqual(self.root.tk.globalgetvar(optmenu2_stringvar_name), items[2]) optmenu.destroy() optmenu2.destroy()
def __init__(self, parent, labbook_dir=os.path.join(os.getcwd(), 'labbook'), text="Labbook", fExt='.txt', font=("Helvetica", 16), **kwargs): tk.LabelFrame.__init__(self, parent, text=text, font=font, **kwargs) self.parent = parent self.textWid = ScrolledText.ScrolledText(self) self.labbook_dir = labbook_dir self.fExt = fExt r = re.compile('\d{1,2}-\d{1,2}-\d{2,4}.*' + self.fExt) self.dropdownOptions = self.sortDates([ y.group() for y in [r.match(x) for x in os.listdir(self.labbook_dir)] if y is not None ]) self.dropdownVar = tk.StringVar() self.configureForCurrentDate() topFrame = tk.Frame(self) self.dropdown = ttk.OptionMenu( topFrame, self.dropdownVar, self.dropdownVar.get(), *self.dropdownOptions, command=lambda x: self.labbookSelected(self.dropdownVar), style='Files.TMenubutton') icon = Image.open("icons/refresh_icon.png").resize((20, 20)) icon = ImageTk.PhotoImage(icon) self.refreshButton = tk.Button(topFrame, image=icon, command=self.configureForCurrentDate, height=20, width=20) self.refreshButton.image = icon # store the image as a variable in the widget to prevent garbage collection. self.dropdown.pack(side=tk.LEFT) self.refreshButton.pack(side=tk.RIGHT) topFrame.pack(side=tk.TOP, fill=tk.X, padx=15, pady=5) self.textWid.pack(expand=1)
def test_initialization(self): self.failUnlessRaises(tkinter.TclError, ttk.OptionMenu, None, self.textvar, invalid='thing') optmenu = ttk.OptionMenu(None, self.textvar, 'b', 'a', 'b') self.failUnlessEqual(optmenu._variable.get(), 'b') self.failUnless(optmenu['menu']) self.failUnless(optmenu['textvariable']) optmenu.destroy()
def run(self): c = Tkinter.Canvas(width=self.width, height=self.height, bg=self.bg) c.pack() c.bind("<Button-1>", self.click1) c.bind("<Button-2>", self.click2) c.bind("<ButtonRelease-2>", self.release2) c.bind("<B2-Motion>", self.drag2) c.winfo_toplevel().resizable(0, 0) frame = Tkinter.Frame() self.player_var = Tkinter.StringVar(c) self.player_select = ttk.OptionMenu(frame, self.player_var) self.player_var.trace('w', self.set_current_player) self.player_select.pack() self.verb_var = Tkinter.StringVar(c) self.verb_select = ttk.OptionMenu(frame, self.verb_var) self.verb_var.trace('w', self.set_current_verb) self.verb_select.pack() self.get_menus() self.undo_button = Tkinter.Button(frame, text="Undo", command=self.undo, state=Tkinter.DISABLED) self.undo_button.pack() c.create_window(0, 0, window=frame, anchor=Tkinter.NW) frame.pack self.canvas = c self.create_handles() self.draw_all() c.mainloop()
def _setup_widgets(self): self.pack(fill='both', expand=True) ttk.Label(self, text="Course").grid(row=0, column=0, sticky=W) course_menu = ttk.OptionMenu(self, self.selected_course, courses[0].name, *[x.name for x in courses]) course_menu.grid(row=1, column=0, sticky='w') self.selected_course.trace("w", self.course_changed) self.assignment_tree = ttk.Treeview(self, columns=['Assignment'], selectmode='browse', show='headings') self.assignment_tree.grid(row=2, column=0, sticky='wens') self.assignment_tree.pack(fill='x') self.load_assignment_tree() ttk.Button(self, text="Create Files", command=generate_grade_files).grid(row=3, column=0, sticky="w") for child in self.winfo_children(): child.grid_configure(padx=1, pady=1)
def makePortSettings(self, root): connFrame = ttk.LabelFrame(root, text = Local('Connection')) connFrame.pack(side = 'top', fill = 'x', padx = 3, pady = 3) portFrame = ttk.Frame(connFrame) portFrame.pack(side = 'top') ttk.Label(portFrame, text = Local('Port')).pack(side = 'left', padx = 3, pady = 3) self.port = StringVar() self.portOpt = ttk.OptionMenu(portFrame, self.port) self.portOpt.pack(side = 'left', padx = 3, pady = 3) ttk.Button(portFrame, text = Local('Read'), command = lambda: self.readButton()).pack(side = 'left', padx = 3, pady = 3) ttk.Button(portFrame, text = Local('Write'), command = lambda: self.writeButton()).pack(side = 'left', padx = 3, pady = 3) self.readEventHist = IntVar(value = 1) ttk.Checkbutton(connFrame, text = Local('Read event history'), variable=self.readEventHist).pack(side = 'top', anchor = 'w', padx = 3, pady = 3) self.readTempStat = IntVar(value = 1) ttk.Checkbutton(connFrame, text = Local('Read temperature statistics'), variable=self.readTempStat).pack(side = 'top', anchor = 'w', padx = 3, pady = 3) self.infoLbl = StringVar() ttk.Label(connFrame, textvariable=self.infoLbl, foreground = 'red').pack(side = 'top')
def __init__(self, master, controller, instruments): tk.Frame.__init__(self, master) #self.grid_rowconfigure(0,weight=1) self.grid_rowconfigure(1,weight = 1) self.grid_columnconfigure(0,weight = 1) self.instruments = instruments self.lakeshore = self.instruments['lakeshore'] self.fluke8808a = self.instruments['fluke8808a'] self.keithley = self.instruments['keithley'] self.selectedinstrument = self.lakeshore self.instrument_frame = tk.Frame(self) self.instrument_frame.grid(row = 0, column = 0, sticky = 'nsew') self.instrument_frame.grid_rowconfigure(0,weight=1) self.instrument_frame.grid_columnconfigure(0,weight=1) self.instrumentstr = tk.StringVar() self.instrumentlist = self.instruments.keys() self.instrumentstr.set(self.instrumentlist[0]) self.instrumentmenu = ttk.OptionMenu(self.instrument_frame, self.instrumentstr, self.instrumentlist[0], *self.instrumentlist) self.instrumentmenu.grid(row = 0, column = 0, sticky = 'nsew') self.setinstrumentbtn = ttk.Button(self.instrument_frame, text = "Set Instrument", command = lambda: self.set_instrument()) self.setinstrumentbtn.grid(row = 0, column = 1, sticky = 'wns') self.response_frame = tk.Frame(self) self.response_frame.grid(row = 1, column = 0, sticky = 'nsew') self.response_frame.grid_rowconfigure(0, weight = 1) self.response_frame.grid_columnconfigure(0,weight = 1) self.v = tk.StringVar() self.response_txt = tk.Text(self.response_frame, background = "white", ) self.response_txt.grid(row = 0, column = 0, sticky = "nsew", padx = 5, pady = 5) self.scrollb = ttk.Scrollbar(self.response_frame, command = self.response_txt.yview) self.scrollb.grid(row = 0, column = 1, sticky = 'nsew') self.response_txt['yscrollcommand'] = self.scrollb.set self.entry_frame = tk.Frame(self) self.entry_frame.grid(row = 2, column = 0, sticky = 'ew') self.entry_frame.grid_rowconfigure(0, weight = 1) self.entry_frame.grid_columnconfigure(0, weight = 1) self.entry = ttk.Entry(self.entry_frame, background = "white") self.entry.pack(side = "left", fill = tk.X, expand = True, padx = 5, pady = 5) self.btn_send = ttk.Button(self.entry_frame, text = "Send", command = lambda: self.send_query()) self.btn_send.pack(side = "left")
def __init__(self, parent): """ Display Function 4 GUI. :param ttk.Frame parent: Parent frame. :rtype: Function4GUI :return: Function 4 GUI. """ ttk.Frame.__init__(self, parent) # Row 0 self.top_frame = ttk.Frame(self) self.top_frame.grid(row=0, column=0, sticky=Tk.NSEW) self.top_frame.grid_columnconfigure(0, weight=1) self.option_menu = ttk.OptionMenu(self.top_frame, None) self.option_menu.grid(row=0, column=1, sticky=Tk.NE) self.back_button = ttk.Button(self.top_frame, text="Back") self.back_button.grid(row=0, column=2, padx=(2, 0), sticky=Tk.NE) # Row 1 self.label = ttk.Label(self, anchor=Tk.NW, text="List of registered company that is awarded at least a procurement:") self.label.grid(row=1, column=0, pady=(0, 4), sticky=Tk.NSEW) self.bottom_frame = ttk.Frame(self) self.bottom_frame.grid(row=2, column=0, columnspan=2, pady=(0, 2), sticky=Tk.NSEW) self.bottom_frame.grid_rowconfigure(0, weight=1) self.bottom_frame.grid_columnconfigure(0, weight=1) self.registered_contractors_awarded_listbox = Tk.Listbox(self.bottom_frame, selectmode=Tk.SINGLE) self.registered_contractors_awarded_listbox.grid(row=0, column=0, padx=2, sticky=Tk.NSEW) self.registered_contractors_awarded_listbox_scrollbar_y = ttk.Scrollbar(self.bottom_frame, command=self.registered_contractors_awarded_listbox.yview) self.registered_contractors_awarded_listbox_scrollbar_y.grid(row=0, column=1, sticky=Tk.NSEW) self.registered_contractors_awarded_listbox.configure( yscrollcommand=self.registered_contractors_awarded_listbox_scrollbar_y.set) self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(2, weight=1)
def build_gui(self): self.root.title('TITLE') self.option_add('*tearOff', 'FALSE') label = ttk.Label(self.root, text='text') label.grid(column=0, row=0) folders = ['folderA', 'folderB', 'folderC'] self.folder_var = tkinter.StringVar() menu = ttk.OptionMenu(self.root, self.folder_var, *folders, command=self.handle_cmd) menu.config(width=50) menu.grid(column=1, row=0, sticky='we') end_row = self.build_radios(start_row=1) label_entry_info = [ ('local file path', '...this entry support drag file in'), ('run command', 'C:\\notepad2\\notepad2.exe'), ] for text, default_value in label_entry_info: label, entry = self.build_label_value_block(text, default_value, position=(end_row, 0), entry_size=30) self.widget_dict[text] = entry end_row += 1 # 给 widget 添加拖放方法 local_path_entry = self.widget_dict['local file path'] self.add_drop_handle(local_path_entry, self.handle_drop_on_local_path_entry) self.main_button = ttk.Button(self.root, text='text', command=self.print_main_button_method) self.main_button.grid(row=end_row + 1, column=0, columnspan=2, sticky='we') self.build_logger_panel(end_row + 2)
def de_widget(self): # Initialize widget self.init_widget() # strategy self.strategy_label = ttk.Label(self.frame1.sliders, text = "Strategy") self.strategy_option_menu = ttk.OptionMenu(self.frame1.sliders, self.strategy, self.strategy.get(), *sorted(self.STRATOPT)) self.strategy_label.place(relx = 0, x = 0, y = 5, anchor = "nw") self.strategy_option_menu.place(relx = 0, x = 70, y = 3, anchor = "nw") # CR self._label("Crossover probability", 2) self._scale(0., 1., 0.01, self.CR, 2) self._entry(self.CR, 2) # F self._label("Differential weight", 4) self._scale(0., 2., 0.01, self.F, 4) self._entry(self.F, 4)
def __init__(self): serial_list = ['None'] self.startTimer(1,False) tk.Tk.__init__(self) #self.server_running = False f0 = ttk.Frame(self) self.var = StringVar() f0.pack() self.dropdown = ttk.OptionMenu(f0, self.var, serial_list[0], *serial_list) self.dropdown.pack() self.dropdown.configure(state='normal') f6 = ttk.Frame(self) f7 = ttk.Frame(self) f8 = ttk.Frame(self) f9 = ttk.Frame(self) self.start_serial_btn = ttk.Button(f6, text="Start serial", command=self.start_serial) self.start_serial_btn.pack(side='left',padx=10) self.stop_serial_btn = ttk.Button(f7, text="Stop serial", command=self.stop_serial) self.stop_serial_btn.pack(side='left',padx=10) self.start_recording_btn = ttk.Button(f8, text="Start recording", command=self.start_recording) self.start_recording_btn.pack(side='left',padx=10) self.stop_recording_btn = ttk.Button(f9, text="Stop recording", command=self.stop_recording) self.stop_recording_btn.pack(side='left',padx=10) self.start_serial_btn.configure(state='normal') self.stop_serial_btn.configure(state='disable') self.start_recording_btn.configure(state='normal') self.stop_recording_btn.configure(state='disable') f0.grid(column=1,row=0,columnspan=3,padx=10,pady=10,sticky='w') f6.grid(column=1,row=1,padx=10,pady=10,sticky='w') f7.grid(column=2,row=1,padx=10,pady=10,sticky='w') f8.grid(column=1,row=2,padx=10,pady=10,sticky='w') f9.grid(column=2,row=2,padx=10,pady=10,sticky='w')
def __init__(self, parent, proj_name): #### read in the proposal info file try: apps = file(proj_name + "/apps.csv", "r") except IOError as e: print 'Could not open apps.csv' quit() self.project = proj_name self.reviews = [] self.widgets_valid = False self.num_reviews = 0 self.prioritm_proposal = "--not yet defined--" self.prioritm_criterion = "--not yet defined--" self.prioritm_field = "--not yet defined--" self.priorobj_criterion = criterion() self.priorobj_criterion.fields[ 'general comments'] = '--not yet entered--' self.priorobj_criterion.fields['weaknesses'] = '--not yet entered--' self.priorobj_criterion.fields['strengths'] = '--not yet entered--' self.due_date_str = apps.readline().split(':')[1].rstrip().strip() print(' Reviews Due Date: ' + self.due_date_str) print('------') for line in apps: # TODO: use csv module for ignoring , in quoted strings. keys = line.split(',') tmpIDstring = keys[0].strip() ## look for a pickle file # and if its present load it into new review obect r = restore_review( proj_name, tmpIDstring) # check for pickle or start a new review self.num_reviews += 1 r.PI = keys[2].strip() r.Title = keys[1].strip() r.Institution = keys[3].strip() #print 'Opening: ', r.PI, r.Title, r.Institution self.reviews.append(r) self.rev_menu_items = [] for r in self.reviews: #self.rev_ids.append(r.ID) #self.rev_menu_items.append(r.ID + ' | ' + r.Title) self.rev_menu_items.append(r.ID) # make the id prop_index #self.prop_index[r.ID] = r ttk.Frame.__init__(self, parent) self.parent = parent # create a ttk style s1 = ttk.Style() s1.configure('PRT.TFrame', background=col_dark) s2 = ttk.Style() s2.configure('PRT.TButton', background=col_light) s3 = ttk.Style() s3.configure('PRT.TLabel', background=col_txtbg) s4 = ttk.Style() s4.configure('PRT.TText', background=col_txtbg) s5 = ttk.Style() s5.configure('PRT.TMenubutton', background=col_light, width=20) s6 = ttk.Style() s6.configure('NIH2.TMenubutton', background=col_light, width=12) self.parent.title("Proposal Review Tool: " + proj_name + ' due: ' + self.due_date_str) # PRT! self.pack(fill=Tk.BOTH, expand=True) # Build the frame hierarchy #self.window_frame = ttk.Frame(self) self.top_frame = ttk.Frame(self, style='PRT.TFrame') self.top_frame.pack(fill=Tk.X) self.prop_info_frame = ttk.Frame(self, style='PRT.TFrame') self.prop_info_frame.pack(fill=Tk.X) self.criterion_frame = ttk.Frame(self, style='PRT.TFrame') self.criterion_frame.pack(fill=Tk.X) self.text_frame = ttk.Frame(self, style='PRT.TFrame') self.text_frame.pack(fill=Tk.X) self.button_bar_frame = ttk.Frame(self, style='PRT.TFrame') self.button_bar_frame.pack(fill=Tk.X) # start populating the frames ### top frame # Arrows self.updn_arrow_frame = ttk.Frame(self.top_frame, style='PRT.TFrame') self.updn_arrow_frame.pack(side=Tk.LEFT, padx=5, expand=False) self.pic_up = Tk.PhotoImage(file=icon_dir + "up.png") self.but_up = ttk.Button(self.updn_arrow_frame, image=self.pic_up, command=lambda x='up': self.click(x), style='PRT.TButton') self.but_up.pack(side=Tk.TOP) self.pic_dn = Tk.PhotoImage(file=icon_dir + "down.png") self.but_dn = ttk.Button(self.updn_arrow_frame, image=self.pic_dn, command=lambda x='dn': self.click(x), style='PRT.TButton') self.but_dn.pack(side=Tk.BOTTOM) self.top_selector_frame = ttk.Frame(self.top_frame, style='PRT.TFrame') self.top_selector_frame.pack(fill=Tk.X, padx=5, expand=True) self.selitm_proposal = Tk.StringVar( self.top_selector_frame) # Select Proposal self.menu_proposal = ttk.OptionMenu( self.top_selector_frame, self.selitm_proposal, "", *self.rev_menu_items, command=lambda x='WidgetName': self.click(x), style='PRT.TMenubutton') self.menu_proposal['menu'].invoke(0) self.selobj_proposal = self.reviews[0] self.menu_proposal.pack(side=Tk.LEFT) #self.id_string = Tk.StringVar(self.prop_info_frame) #self.prop_display = ttk.Label(self.prop_info_frame,text=self.id_string, width=35) #self.id_string.s #self.id_string = Tk.StringVar(self.prop_info_frame) self.prop_display = ttk.Label(self.prop_info_frame, text="PI: Institution: ", width=150, style='PRT.TLabel') #self.id_string.set("PI: Institution: ") self.prop_display.pack(side=Tk.LEFT, expand=False) # Save buttons self.but_output_scores = ttk.Button( self.top_selector_frame, text="Make scores.csv", width=13, command=lambda x='csv_report': self.click(x), style='PRT.TButton') self.but_output_scores.pack(side=Tk.RIGHT) self.but_output_file = ttk.Button( self.top_selector_frame, text="Make rev.txt", width=13, command=lambda x=False: self.selobj_proposal.human_output(x), style='PRT.TButton') self.but_output_file.pack(side=Tk.RIGHT) self.but_output_progress_data = ttk.Button( self.top_selector_frame, text="Progress Graph", width=13, command=lambda x=False: self.prog_data_graph(), style='PRT.TButton') self.but_output_progress_data.pack(side=Tk.RIGHT) self.but_open_pdf = ttk.Button(self.top_selector_frame, text="View", width=13, command=lambda x='view': self.click(x), style='PRT.TButton') self.but_open_pdf.pack(side=Tk.RIGHT, padx=10) ### prop_info_frame ### criterion_frame self.lr_arrow_frame = ttk.Frame(self.criterion_frame, style='PRT.TFrame') self.lr_arrow_frame.pack(side=Tk.LEFT, padx=5, pady=5) self.pic_left = Tk.PhotoImage(file=icon_dir + "left.png") self.but_left = ttk.Button(self.lr_arrow_frame, image=self.pic_left, command=lambda x='left': self.click(x), style='PRT.TButton') self.but_left.pack(side=Tk.LEFT, padx=5, pady=5) self.pic_right = Tk.PhotoImage(file=icon_dir + "right.png") self.but_right = ttk.Button(self.lr_arrow_frame, image=self.pic_right, command=lambda x='right': self.click(x), style='PRT.TButton') self.but_right.pack(side=Tk.LEFT, padx=5, pady=5) # Criteria Optionmenu self.selitm_criterion = Tk.StringVar(self.criterion_frame) self.crit_menu_items = [] if (len(self.selobj_proposal.criteria) < 1): print 'This proposal has no criteria:' print self.selobj_proposal.name quit() for c in self.selobj_proposal.criteria: self.crit_menu_items.append(c.name) self.menu_criterion = ttk.OptionMenu( self.criterion_frame, self.selitm_criterion, '', *self.crit_menu_items, command=lambda x='WidgetName': self.click(x), style='PRT.TMenubutton') self.menu_criterion.pack(side=Tk.LEFT, expand=False, padx=5, pady=5) self.menu_criterion['menu'].invoke(0) self.selobj_criterion = self.selobj_proposal.criteria[0] # button for Criterion instructions (if any) self.but_crit_help = ttk.Button(self.criterion_frame, text='?', width=2, command=lambda: self.help_popup(), style='PRT.TButton') self.but_crit_help.pack(side=Tk.LEFT, padx=5) # canned text buttons # enter 'N/A' into the field self.but_NA = ttk.Button(self.criterion_frame, text="N/A", command=lambda x='N/A': self.click(x), style='PRT.TButton') self.but_NA.pack(side=Tk.RIGHT, padx=5, pady=5) # enter 'None' into the field self.but_none = ttk.Button(self.criterion_frame, text="None", command=lambda x='None': self.click(x), style='PRT.TButton') self.but_none.pack(side=Tk.RIGHT, padx=5, pady=5) # copy this text in window to same field in all proposals self.but_clone = ttk.Button(self.criterion_frame, text="Clone", command=lambda x='Clone': self.click(x), style='PRT.TButton') self.but_clone.pack(side=Tk.RIGHT, padx=5, pady=5) # Field Optionmenu self.selitm_field = Tk.StringVar(self.criterion_frame) self.field_menu_items = [] for field, text in self.selobj_criterion.fields.iteritems(): self.field_menu_items.append(field) self.menu_fields = ttk.OptionMenu( self.criterion_frame, self.selitm_field, '', *self.field_menu_items, command=lambda x='field_menu': self.click(x), style='NIH2.TMenubutton') self.menu_fields.pack(side=Tk.LEFT, expand=False, padx=5) self.menu_fields['menu'].invoke(0) #self.selobj_field = self.selobj_criterion.fields[self.selitm_field.get()] ######################################## SCORE self.score_val = Tk.StringVar(self) self.score_val.set("0") self.score_widget = Tk.Spinbox(self.criterion_frame, from_=1, to=9, increment=1, state=Tk.DISABLED, width=5, textvariable=self.score_val, bg=col_txtbg) self.score_widget.pack(side=Tk.LEFT, padx=5, pady=5) #### text_frame self.text_widget = Tk.Text(self.text_frame, background=col_txtbg) self.text_widget.pack(fill=Tk.BOTH, expand=True) #### button_bar_frame but_save = ttk.Button(self.button_bar_frame, text="Save", width=8, command=self.save_proposal, style='PRT.TButton') but_save.pack(side=Tk.LEFT, anchor=Tk.N, padx=5, pady=5) but_quit = ttk.Button(self.button_bar_frame, text="Quit", width=8, command=self.quit_popup, style='PRT.TButton') but_quit.pack(side=Tk.RIGHT, anchor=Tk.N, padx=5, pady=5) # progress indicator labels self.prog_value = ttk.Label(self.button_bar_frame, text='0.0', width=35, background=col_txtbg) self.prog_value.pack(side=Tk.RIGHT, anchor=Tk.N, padx=5, pady=5) self.widgets_valid = True # enable the widgets post-setup self.prog_label = ttk.Label(self.button_bar_frame, text=prog_definition_string, width=prog_def_width, background=col_dark) self.prog_label.pack(side=Tk.RIGHT, anchor=Tk.N, padx=5, pady=5)
imp = ttk.Button(leftFrame, text='Import File', command=Handler, width=14, takefocus=False) imp.grid(row=3, column=0, columnspan=2) u = ttk.Label(leftFrame, text="Unit (nm): ") u.grid(row=4, column=0, pady=20) #label v = ttk.Entry(leftFrame, textvariable=unit, width=8, cursor='xterm') v.grid(row=4, column=1) #entry textbox u1 = ttk.Label(leftFrame, text="Levels: ") u1.grid(row=5, column=0, pady=0) #label optionList = ["2", "4", "8", "16", "32", "64"] dropVar = StringVar(root) dropVar.set(2) popupMenu = ttk.OptionMenu(leftFrame, dropVar, optionList[0], *optionList) popupMenu.config(width=4) popupMenu.grid(row=5, column=1) conv = ttk.Button(leftFrame, text='Convert to GDSII', command=lambda: gdsConv(v.get(), dropVar.get()), takefocus=False) conv.grid(row=6, column=0, pady=20, columnspan=2) periodic = ttk.Button(leftFrame, text='About', command=about, width=14, takefocus=False) periodic.grid(row=7, column=0, columnspan=2, pady=0) root.mainloop()
def periodicStructures(): rightFrame.grid_propagate(0) global r r = IntVar(root) for widget in rightFrame.winfo_children(): widget.destroy() R1 = Radiobutton(rightFrame, text="Triangle", variable=r, value=1, font='calibri 12 bold') R1.grid(row=0, column=0, sticky=W, rowspan=2, padx=25) R2 = Radiobutton(rightFrame, text="Circle", variable=r, value=2, font='calibri 12 bold') R2.grid(row=2, column=0, sticky=W, rowspan=2, padx=25) R3 = Radiobutton(rightFrame, text="Rectangle", variable=r, value=3, font='calibri 12 bold') R3.grid(row=4, column=0, sticky=W, rowspan=2, padx=25) ima = imMaker(resource_path('Triangle.png'), 122) la = Label(rightFrame, image=ima) la.imag = ima la.grid(row=0, column=1, sticky=W, rowspan=2) imb = imMaker(resource_path('Circle.png'), 120) lb = Label(rightFrame, image=imb) lb.imag = imb lb.grid(row=2, column=1, sticky=W, rowspan=2) imc = imMaker(resource_path('Rectangle.png'), 120) lc = Label(rightFrame, image=imc) lc.imag = imc lc.grid(row=4, column=1, sticky=W, rowspan=2) ###Triangle u2 = Label(rightFrame, text="Base: ", font=("calibri 12 bold")) u2.grid(row=0, column=2, sticky=W, padx=25) #label base = IntVar(root) v2 = ttk.Entry(rightFrame, textvariable=base, width=12, cursor='xterm') v2.grid(row=0, column=3, sticky=W, padx=25) #entry textbox u3 = Label(rightFrame, text="Height: ", font=("calibri 12 bold")) u3.grid(row=1, column=2, sticky=W, padx=25) #label height = IntVar(root) v3 = ttk.Entry(rightFrame, textvariable=height, width=12, cursor='xterm') v3.grid(row=1, column=3, sticky=W, padx=25) #entry textbox ###Circle u4 = Label(rightFrame, text="Radius: ", font=("calibri 12 bold")) u4.grid(row=2, column=2, sticky=W, padx=25) #label radius = IntVar(root) v4 = ttk.Entry(rightFrame, textvariable=radius, width=12, cursor='xterm') v4.grid(row=2, column=3, sticky=W, padx=25) #entry textbox #u5 = Label(rightFrame, text="Eccentricity: ", font = ("calibri 12 bold")) #u5.grid(row = 3, column = 2, sticky = W,padx = 15)#label #ecc = IntVar(root) #v5= Entry(rightFrame, textvariable = ecc, width = 8) #v5.grid(row = 3 , column = 3, sticky = W, padx = 15)#entry textbox #Rectangle u6 = Label(rightFrame, text="Length: ", font=("calibri 12 bold")) u6.grid(row=4, column=2, sticky=W, padx=25) #label leng = IntVar(root) v6 = ttk.Entry(rightFrame, textvariable=leng, width=12, cursor='xterm') v6.grid(row=4, column=3, sticky=W, padx=25) #entry textbox u7 = Label(rightFrame, text="Breadth: ", font=("calibri 12 bold")) u7.grid(row=5, column=2, sticky=W, padx=25) #label breadth = IntVar(root) v7 = ttk.Entry(rightFrame, textvariable=breadth, width=12, cursor='xterm') v7.grid(row=5, column=3, sticky=W, padx=25) #entry textbox ###Row and Column repetitions u8 = Label(rightFrame, text="Rows: ", font=("calibri 12 bold")) u8.grid(row=6, column=0, sticky=W, padx=25, pady=15) #label rows = IntVar(root) v8 = ttk.Entry(rightFrame, textvariable=rows, width=16, cursor='xterm') v8.grid(row=6, column=1, sticky=W, padx=10) #entry textbox u9 = Label(rightFrame, text="Columns: ", font=("calibri 12 bold")) u9.grid(row=6, column=2, sticky=W, padx=25) #label cols = IntVar(root) v9 = ttk.Entry(rightFrame, textvariable=cols, width=12, cursor='xterm') v9.grid(row=6, column=3, sticky=W, padx=25) #entry textbox u10 = Label(rightFrame, text="Period: ", font=("calibri 12 bold")) u10.grid(row=7, column=0, sticky=W, padx=25, pady=15) #label period = IntVar(root) v10 = ttk.Entry(rightFrame, textvariable=period, width=16, cursor='xterm') v10.grid(row=7, column=1, sticky=W, padx=10, pady=10) #entry textbox u11 = Label(rightFrame, text="Mode:", font=("calibri 12 bold")) u11.grid(row=7, column=2, padx=25, sticky=W) #label modeList = ["0", "1"] modeVar = StringVar(root) modeVar.set("0") modMenu = ttk.OptionMenu(rightFrame, modeVar, modeList[0], *modeList) modMenu.config(width=8) modMenu.grid(row=7, column=3, sticky=W, padx=25) generate = ttk.Button( rightFrame, text='Generate', command=lambda: gdsGenerate(r.get(), v2.get(), v3.get(), v4.get( ), v6.get(), v7.get(), v8.get(), v9.get(), v10.get(), modeVar.get()), takefocus=False) generate.grid(row=8, column=0, sticky=W + E + N + S, pady=20) m = '' message = Label(rightFrame, text=m, font='calibri 12 bold', fg='red') message.grid(row=8, column=1, columnspan=3, sticky=W) def gdsGenerate(s, base, height, radius, leng, breadth, rows, cols, period, mod): mod = int(mod) if s == 0: m = 'Select a shape!' message.config(text=m) message.text = m elif s == 1: if base == '0' or (not str.isdigit(base)): m = 'Enter Valid Base value!' message.config(text=m, fg='red') message.text = m elif height == '0' or (not str.isdigit(height)): m = 'Enter Valid Height value!' message.config(text=m, fg='red') message.text = m else: if rows != 0 and cols != 0 and period != 0 and ( str.isdigit(rows)) and (str.isdigit(cols)) and ( str.isdigit(period)): f = f = tkFileDialog.asksaveasfilename() if f == None: m = 'Choose a save location!' message.config(text=m, fg='red') message.text = m else: cell = core.Cell('Triangle') layout = core.Layout('Triangle', unit=1e-9) if mod == 0: points = [(0, 0), (float(base), 0), (float(base) / 2.0, float(height))] cell.add(core.Boundary(points)) cellArray = core.Cell('TriangleArray') cellArray.add( core.CellArray(cell, int(cols), int(rows), (int(period), int(period)))) layout.add(cellArray) layout.save(f + '.gds') m = 'GDSII generated!' message.config(text=m, fg='blue') message.text = m elif mod == 1: height = float(height) rows = int(rows) cols = int(cols) period = float(period) print 'hi' for i in range(rows): for j in range(cols): points = [(period * j, i * period), (float(base) + period * j, i * period), (float(base) / 2.0 + period * j, height + i * period)] cell.add(core.Boundary(points)) layout.add(cell) layout.save(f + '.gds') m = 'GDSII generated!' message.config(text=m, fg='blue') message.text = m else: m = 'Enter valid rows, columns and period!' message.config(text=m, fg='red') message.text = m elif s == 2: if radius == '0' or (not str.isdigit(radius)): m = 'Enter Valid Radius value!' message.config(text=m, fg='red') message.text = m else: if rows != 0 and cols != 0 and period != 0 and ( str.isdigit(rows)) and (str.isdigit(cols)) and ( str.isdigit(period)): f = tkFileDialog.asksaveasfilename() if f == None: m = 'Choose a save location!' message.config(text=m, fg='red') message.text = m else: cell = core.Cell('Circle') layout = core.Layout('CircleLayout', unit=1e-9) if mod == 0: cell.add(shapes.Disk((0, 0), float(radius))) cellArray = core.Cell('CircleArray') cellArray.add( core.CellArray(cell, int(cols), int(rows), (int(period), int(period)))) layout.add(cellArray) #layout.save(f) layout.save(f + '.gds') m = 'GDSII generated!' message.config(text=m, fg='blue') message.text = m elif mod == 1: radius = float(radius) rows = int(rows) cols = int(cols) period = float(period) print 'hi' for i in range(rows): for j in range(cols): cell.add( shapes.Disk((period * j, period * i), float(radius))) layout.add(cell) layout.save(f + '.gds') m = 'GDSII generated!' message.config(text=m, fg='blue') message.text = m else: m = 'Enter valid rows, columns and period!' message.config(text=m, fg='red') message.text = m elif s == 3: if leng == '0' or not (str.isdigit(leng)): m = 'Enter Valid Length value!' message.config(text=m, fg='red') message.text = m elif breadth == '0' or (not str.isdigit(breadth)): m = 'Enter Valid Breadth value!' message.config(text=m, fg='red') message.text = m else: if rows != 0 and cols != 0 and period != 0 and ( str.isdigit(rows)) and (str.isdigit(cols)) and ( str.isdigit(period)): f = tkFileDialog.asksaveasfilename() if f == None: m = 'Choose a save location!' message.config(text=m, fg='red') message.text = m else: cell = core.Cell('Rectangle') layout = core.Layout('RectangleLayout', 1e-9) if mod == 0: cell.add( shapes.Rectangle( (0, 0), (float(leng), float(breadth)))) cellArray = core.Cell('RectangleArray') cellArray.add( core.CellArray(cell, int(cols), int(rows), (int(period), int(period)))) layout.add(cellArray) layout.save(f + '.gds') m = 'GDSII generated!' message.config(text=m, fg='blue') message.text = m elif mod == 1: leng = float(leng) breadth = float(breadth) rows = int(rows) cols = int(cols) period = float(period) print 'hi' for i in range(rows): for j in range(cols): cell.add( shapes.Rectangle( (period * j, period * i), (float(leng) + period * j, float(breadth) + period * i))) layout.add(cell) layout.save(f + '.gds') m = 'GDSII generated!' message.config(text=m, fg='blue') message.text = m else: m = 'Enter valid rows, columns and period!' message.config(text=m, fg='red') message.text = m
def __init__(self): serial_list = ['시리얼 포트를 선택하세요.'] self.startTimer(1, False) tk.Tk.__init__(self) self.serial_running = False f0 = ttk.Frame(self) self.var = StringVar() f0.pack() self.dropdown = ttk.OptionMenu(f0, self.var, serial_list[0], *serial_list, command=self.OptionMenu_Selected( self.var)) self.dropdown.pack() self.dropdown.configure(state='normal') self.var.trace('w', self.OptionMenu_Changed) f1 = ttk.Frame(self) # button: start serial f2 = ttk.Frame(self) # button: stop serial f3 = ttk.Frame(self) # link 0 f4 = ttk.Frame(self) # link 1 f5 = ttk.Frame(self) # link 2 f6 = ttk.Frame(self) # button: save #f7 = ttk.Frame(self) # #f8 = ttk.Frame(self) # # start serial button self.start_serial_btn = ttk.Button(f1, text="Start serial", command=self.start_serial) self.start_serial_btn.pack(side='left', padx=10) self.start_serial_btn.configure(state='disable') # stop serial button self.stop_serial_btn = ttk.Button(f2, text="Stop serial", command=self.stop_serial) self.stop_serial_btn.pack(side='left', padx=10) self.stop_serial_btn.configure(state='disable') #Link 0 ttk.Label(f3, text='Link 0: ', font='Helvetica 10 bold').pack(side='left') self.port = ttk.Entry(f3, width=6) self.port.insert('end', '80') self.port.pack(side='left', padx=0, pady=10) #Link 1 ttk.Label(f4, text='Link 1: ', font='Helvetica 10 bold').pack(side='left') self.port = ttk.Entry(f4, width=6) self.port.insert('end', '80') self.port.pack(side='left', padx=0, pady=10) #lin 3 ttk.Label(f5, text='Link 2: ', font='Helvetica 10 bold').pack(side='left') self.port = ttk.Entry(f5, width=6) self.port.insert('end', '80') self.port.pack(side='left', padx=0, pady=10) # save btn self.save_link_btn = ttk.Button(f6, text="save link", command=self.save_link) self.save_link_btn.pack(side='left', padx=10) f0.grid(column=1, row=0, columnspan=3, padx=10, pady=10, sticky='w') f1.grid(column=1, row=1, padx=10, pady=10, sticky='w') f2.grid(column=2, row=1, padx=10, pady=10, sticky='w') f3.grid(column=1, row=2, padx=10, pady=10, sticky='w') f4.grid(column=2, row=2, padx=10, pady=10, sticky='w') f5.grid(column=3, row=2, padx=10, pady=10, sticky='w') f6.grid(column=4, row=2, padx=10, pady=10, sticky='w')