def main(): root = Tk() root.geometry("600x185+200+200") app = MemberChecker(root) menubar = Menu(root) menubar.add_command(label="Clear log", command=app.clear_log) menubar.add_command(label="Load API data", command=app.load_data) root.config(menu=menubar) root.pack_slaves() root.mainloop()
def __init__(self): self.master = Tk() self.master.geometry(newGeometry = '300x300') # Fenêtre tkinter self.menu = Menu(self.master) self.filemenu = Menu(self.menu, tearoff = 0) self.filemenu.add_command(label = "Open", command = self.open) self.filemenu.add_separator() self.filemenu.add_command(label = "Exit", command = self.master.destroy) self.menu.add_cascade(label = "File", menu = self.filemenu) self.master.config(menu = self.menu) # On crée un menu self.canvas = Canvas(master=self.master, width=200, height=200, bg='#cccccc') self.canvas.place(x=150, y=100, anchor='center') Label(master=self.master, text='Image', font='YuMinchoDemibold', foreground='white', background='#535353').place(x=120, y=190)
def __init__(self): """ Create the initial application GUI environment (tool bars, and other static elements) """ Frame.__init__(self, self.root) self.thread_entry_field = '' # Hold both search string, and drives autoRefresh logic self.menuBar = Menu() self.fileMenu = Menu(self.menuBar, tearoff=0) self.menuBar.add_cascade(label="File", menu=self.fileMenu, underline=1) self.fileMenu.add_command(label="Quit", command=self.root.destroy, underline=1) self.optionsMenu = Menu(self.menuBar, tearoff=0) self.menuBar.add_cascade(label="Options", menu=self.optionsMenu) self.optionsMenu.add_command(label="Settings", command=self.editSettings, underline=1) self.helpMenu = Menu(self.menuBar, tearoff=0) self.menuBar.add_cascade(label="Help", menu=self.helpMenu) self.helpMenu.add_command(label="Help", command=self.program_help, underline=1) self.helpMenu.add_command(label="About", command=self.program_about, underline=1) self.master.config(menu=self.menuBar) self.topFrame = Frame() self.thread_entry_box = Entry(self.topFrame) self.thread_entry_box.insert(0, self.DEFAULT_THREAD_TEXT) self.thread_entry_box.bind('<Return>', lambda event: self.add_thread_GUI()) # Bind needs to send the event to the handler self.thread_entry_box.pack(side='left', fill='x', expand='True', padx=5) self.add_thread_btn = Button(self.topFrame) self.add_thread_btn['text'] = 'Add New Thread' self.add_thread_btn['command'] = lambda: self.add_thread_GUI() self.add_thread_btn.pack(side='left', padx=0) self.topFrame.pack(fill='x') self.create_thread_frame()
def createWidgets(self): tabControl = ttk.Notebook(self.win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") self.monty = ttk.LabelFrame(tab1, text=' Monty Python ') self.monty.grid(column=0, row=0, padx=8, pady=4) ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W') self.name = tk.StringVar() nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name) nameEntered.grid(column=0, row=1, sticky='W') self.action = ttk.Button(self.monty, text="Click Me!") self.action.grid(column=2, row=1) ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(self.monty, width=12, textvariable=number) numberChosen['values'] = (42) numberChosen.grid(column=1, row=1) numberChosen.current(0) scrolW = 30; scrolH = 3 self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD) self.scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) self.win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) nameEntered.focus()
class Example(Frame): def __init__(self): super().__init__() self.initUI() def initUI(self): self.master.title("Toolbar") menubar = Menu(self.master) self.fileMenu = Menu(self.master, tearoff=0) self.fileMenu.add_command(label="Exit", command=self.onExit) menubar.add_cascade(label="File", menu=self.fileMenu) toolbar = Frame(self.master, bd=1, relief=RAISED) self.img = Image.open("images.png") eimg = ImageTk.PhotoImage(self.img) exitButton = Button(toolbar, image=eimg, relief=FLAT, command=self.quit) exitButton.image = eimg exitButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() def onExit(self): self.quit()
def initUI(self): self.menu_file = Menu(self) self.menu_file.add_command(label='Load 3D') self.menu_file.add_command(label='Load 2D') self.menu_file.add_command(label='Exit',command=self.delegate.quit) self.add_cascade(menu=self.menu_file, label='File') self.menu_Filter = Menu(self) self.b0 = BooleanVar() self.b1 = BooleanVar() self.b2 = BooleanVar() self.b3 = BooleanVar() self.menu_Filter.add_checkbutton(label="Speech 3D", onvalue=1, offvalue=0, variable=self.b0, command=self.delegate.speech3DButtonPressed) self.menu_Filter.add_checkbutton(label='Speech 2D',onvalue=1, offvalue=0, variable=self.b1, command=self.delegate.speech2DButtonPressed) self.menu_Filter.add_checkbutton(label='Swallow 3D',onvalue=1, offvalue=0, variable=self.b2,command=self.delegate.swallow3DButtonPressed) self.menu_Filter.add_checkbutton(label='Swallow 2D',onvalue=1, offvalue=0, variable=self.b3,command=self.delegate.swallow2DButtonPressed) self.add_cascade(menu=self.menu_Filter, label='Filter') self.entryconfigure('Filter', state = 'disabled')
def viewFacts(modelXbrl, tabWin, header="Fact Table", arcrole=XbrlConst.parentChild, linkrole=None, linkqname=None, arcqname=None, lang=None, expandAll=False): modelXbrl.modelManager.showStatus(_("viewing relationships {0}").format(os.path.basename(arcrole))) view = ViewFactTable(modelXbrl, tabWin, header, arcrole, linkrole, linkqname, arcqname, lang, expandAll) view.ignoreDims = BooleanVar(value=False) view.showDimDefaults = BooleanVar(value=False) if view.view(): view.treeView.bind("<<TreeviewSelect>>", view.treeviewSelect, '+') view.treeView.bind("<ButtonRelease-1>", view.treeviewClick, '+') view.treeView.bind("<Enter>", view.treeviewEnter, '+') view.treeView.bind("<Leave>", view.treeviewLeave, '+') # languages menu menu = view.contextMenu() optionsMenu = Menu(view.viewFrame, tearoff=0) view.ignoreDims.trace("w", view.viewReloadDueToMenuAction) optionsMenu.add_checkbutton(label=_("Ignore Dimensions"), underline=0, variable=view.ignoreDims, onvalue=True, offvalue=False) menu.add_cascade(label=_("Options"), menu=optionsMenu, underline=0) view.menuAddExpandCollapse() view.menuAddClipboard() view.menuAddLangs() view.menuAddLabelRoles(includeConceptName=True) #saveMenu = Menu(view.viewFrame, tearoff=0) #saveMenu.add_command(label=_("HTML file"), underline=0, command=lambda: view.modelXbrl.modelManager.cntlr.fileSave(view=view, fileType="html")) #menu.add_cascade(label=_("Save"), menu=saveMenu, underline=0) return view
def __init__(self): # Initialize the text editor self.root = tk.Tk(className='Tekstieditori') # Text editor text area self.textpad = tkst.ScrolledText(self.root, width=100, height=36, highlightthickness=0) # Text area, inner padding and font config added self.textpad.config(font=('tkDefaultFont', 16, 'normal'), padx=10, pady=10) # Add text area to parent self.textpad.pack() # Create a file menu in menu bar self.menu = Menu(self.root) self.filemenu = Menu(self.menu) self.file_menu_conf() self.file = {} # Initialize the selection index class variable self.sel_index = [0, 1] # Configurate click events self.event_config()
class FrontEnd(Frame): def __init__(self, master, version): Frame.__init__(self, master) master.title(version[:-5]) # MAKE IT LOOK GOOD style = Style() style.configure("atitle.TLabel", font="tkDefaultFont 12 bold italic") # CREATE AND SET VARIABLES self.version = version self.description = None self.logo = None self.status_lbl = StringVar() # TO HOLD STATUS VARIABLE IN STATUSBAR # CREATE ROOT MENUBAR menubar = Menu(self.master) self.master["menu"] = menubar self.master.option_add("*tearOff", False) # CREATE FILE MENU self.menu_file = Menu(menubar, name="file") self.menu_file.add_separator() self.menu_file.add_command(label="Exit", accelerator="Alt-F4", command=self.master.destroy) menubar.add_cascade(menu=self.menu_file, label="File", underline=0) # CREATE HELP MENU menu_help = Menu(menubar, name="help") menu_help.add_command(label="About", command=self.show_about) menubar.add_cascade(menu=menu_help, label="Help", underline=0) # CREATE BUTTON BAR self.button_bar = Frame(self.master, relief="groove", padding="0 1 0 2") self.button_bar.grid(sticky="ew") # SETUP PRIMARY FRAME FOR WIDGETS self.frame = Frame(self.master, padding="25") self.frame.grid(sticky="nsew") # CREATE STATUS BAR Separator(self.master).grid(row=8, sticky="ew") self.status_bar = Frame(self.master, padding="8 0 0 1") self.status_bar.grid(row=9, sticky="ews") Label(self.status_bar, textvariable=self.status_lbl).grid(row=0, column=0, padx="0 7") Label(self.status_bar, text=self.version[-5:]).grid(row=0, column=8) Sizegrip(self.status_bar).grid(row=0, column=9, sticky="e") # CONFIGURE AUTO-RESIZING self.master.columnconfigure(0, weight=1) self.master.rowconfigure(1, weight=1) self.frame.columnconfigure(0, weight=1) # self.frame.rowconfigure(0, weight=1) self.status_bar.columnconfigure(1, weight=1) def show_about(self): about = About(self.master, "About {}".format(self.version[:-5]), self.logo) Label(about.frame, text=self.version, style="atitle.TLabel").grid(sticky="w") Label(about.frame, text="Developer: Joel W. Dafoe").grid(pady="6", sticky="w") link = Link(about.frame, text="http://cyberdatx.com", foreground="blue", cursor="hand2") link.grid(sticky="w") link.bind("<Button-1>", lambda e: webbrowser.open("http://cyberdatx.com")) Label(about.frame, text=self.description, wraplength=292).grid(columnspan=2, pady=6, sticky=W)
def contents_widget(self, text): "Create table of contents." toc = Menubutton(self, text='TOC') drop = Menu(toc, tearoff=False) for tag, lbl in text.parser.contents: drop.add_command(label=lbl, command=lambda mark=tag:text.see(mark)) toc['menu'] = drop return toc
def toc_menu(self, text): "Create table of contents as drop-down menu." toc = Menubutton(self, text='TOC') drop = Menu(toc, tearoff=False) for lbl, dex in text.parser.toc: drop.add_command(label=lbl, command=lambda dex=dex:text.yview(dex)) toc['menu'] = drop return toc
class DataEntry(object): def __init__(self, parent_frame, grid_col, grid_row, data): self._data = data self._parent = parent_frame self._frame = ttk.Frame(self._parent, borderwidth=2, relief='sunken') self._frame.grid(column=grid_col, row=grid_row) self._menu = Menu(master=self._parent, tearoff=0) self._menu.add_command(label='info', command=self.info_popup) self._should_plot = tk.BooleanVar() self._should_plot.set(False) def menu_popup(event): self._menu.post(event.x_root, event.y_root) self._chkbox = ttk.Checkbutton(self._frame, text="Plot", variable=self._should_plot, onvalue=True) self._chkbox.pack() self._button = ttk.Button(self._frame, text="{} -> {}".format(grid_row, grid_col), command=self.info_popup ) self._button.pack() self._button.bind('<Button-3>', menu_popup) @property def data(self): return self._data @property def should_plot(self): return self._should_plot.get() def info_popup(self): top = Toplevel() top.title("Info") frame = ttk.Frame(top) frame.pack() sourceLbl = ttk.Label(frame, text="Source") targetLbl = ttk.Label(frame, text="Target") sourceText = ttk.Label(frame, text=str(self._data._source), relief='sunken') targetText = ttk.Label(frame, text=str(self._data._target), relief='sunken') sourceLbl.grid(column=0, row=0) targetLbl.grid(column=1, row=0) sourceText.grid(column=0, row=1, padx=5, pady=5) targetText.grid(column=1, row=1, padx=5, pady=5)
def add_menus(self): menu_bar = Menu(self.root) stampede_menu = Menu(menu_bar, tearoff=0) stampede_menu.add_command(label="Settings", command=self.edit_default_settings) stampede_menu.add_separator() stampede_menu.add_command(label="Quit", command=self.root.quit) menu_bar.add_cascade(label="Stampede", menu=stampede_menu) self.root.config(menu=menu_bar)
def add_menu(self): top = self.root top["menu"] = menubar = Menu(top) menu_file = Menu(menubar) menu_settings = Menu(menubar) menu_help = Menu(menubar) menubar.add_cascade(menu=menu_file, label=_("File")) menubar.add_cascade(menu=menu_settings, label=_("Settings")) menubar.add_cascade(menu=menu_help, label=_("Help")) menu_settings.add_command(label=_("Pannel Settings"), command=self.dlg_panset)
def _place_menu_cascade(menubar: tk.Menu, menu_name: str, postcommand: Callable, menu_items: Sequence[Union[MenuItem, str]], menu_label: str, item_labels: Sequence[str], ): """Create a menu with its menu items. Args: menubar: Parent menu bar. menu_name: Internal name of menu postcommand: Called when the user clicks on the menubar. NB: If three menus have postcommand functions then all three will be called every time the user clicks on the menubar. Postcommand function calls are not restricted to one peculiar to the drop down menu being viewed by the user. menu_items: Handler, initial active state, observer menu_label: User visible menu name item_labels:User visible menu item name """ only_menu_items = [menu_item for menu_item in menu_items if not isinstance(menu_item, str)] if len(only_menu_items) != len(item_labels): msg = ("There should be {} items for '{}' in config.ini." "".format(len(only_menu_items), menu_name)) logging.error(msg=msg) raise ValueError(msg) cascade = tk.Menu(menubar) if postcommand: cascade.config(postcommand=lambda: postcommand(cascade)) item_label = iter(item_labels) for ix, menu_item in enumerate(menu_items): if isinstance(menu_item, str): cascade.add_separator() elif callable(menu_item.handler): label = next(item_label) handler = menu_item.handler if menu_item.active: cascade.add_command(label=label, command=handler, state=tk.ACTIVE) else: cascade.add_command(label=label, command=handler, state=tk.DISABLED) if menu_item.observable: observer = partial(guisupport.menu_item_enable_observer, cascade, ix) menu_item.observable.register(observer) elif not menu_item.handler: cascade.add_command(label=next(item_label), state=tk.DISABLED) else: label = next(item_label) msg = ("The menu item '{}' is not a separator and does not contain a handler." "".format(label)) logging.error(msg=msg) cascade.add_command(label=label, state=tk.DISABLED) menubar.add_cascade(label=menu_label, menu=cascade)
def initUI(self): self.parent.title('PyZilla') self.padding = 5 self.pack(fill=BOTH, expand=1) # Create a menubar mnuMenu = Menu(self.parent) self.parent.config(menu=mnuMenu) # Create menubar mnuFileMenu = Menu(mnuMenu) # Add File menu items mnuFileMenu.add_command(label='Open', command=self.onBtnOpenFile) mnuFileMenu.add_command(label='Exit', command=self.quit) # Add File menu items to File menu mnuMenu.add_cascade(label='File', menu=mnuFileMenu) # Create frame for all the widgets frame = Frame(self) frame.pack(anchor=N, fill=BOTH) # Create file open dialog btnOpenFile = Button(frame, text="Load file", command=self.onBtnOpenFile) btnOpenFile.pack(side=RIGHT, pady=self.padding) # Create filename label self.lblFilename = Label(frame, text='No filename chosen...') self.lblFilename.pack(side=LEFT, pady=self.padding, padx=self.padding) # Create the text widget for the results self.txtResults = Text(self) self.txtResults.pack(fill=BOTH, expand=1, pady=self.padding, padx=self.padding)
def __init__(self, parent, *args, **kwargs): tk.Frame.__init__(self, parent, *args, **kwargs) self.parent = parent self.parent.option_add('*tearOff', False) self.after(50, self.onAfter) #set this frame to expand to %100 available space self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) #init menu menubar = Menu(self.parent) self.parent.config(menu=menubar) fileMenu = Menu(menubar) fileMenu.add_command(label="Save", command=self.onSave) fileMenu.add_command(label="Load", command=self.onLoad) fileMenu.add_command(label="Exit", command=self.onExit) menubar.add_cascade(label="File", menu=fileMenu) #init textbox self.text = ScrolledText(self, wrap='word') #add widgets to the layout manager self.text.grid(sticky=inflate)
def click_right(self, event): menu = Menu(self, tearoff=0) try: self.selection_get() state = 'normal' except TclError: state = 'disabled' menu.add_command(label=_('Copy'), command=self.copy, state=state) menu.add_command(label=_('Cut'), command=self.cut, state=state) menu.add_command(label=_('Paste'), command=self.paste) menu.post(event.x_root, event.y_root)
def CimEditMenu(e): try: e.widget.focus() rmenu = Menu(None, tearoff=0, takefocus=0) rmenu.add_command(label='Cut', command=lambda e=e: e.widget.event_generate('<Control-x>')) rmenu.add_command(label='Copy', command=lambda e=e: e.widget.event_generate('<Control-c>')) rmenu.add_command(label='Paste', command=lambda e=e: e.widget.event_generate('<Control-v>')) rmenu.tk_popup(e.x_root+40, e.y_root+10,entry="0") except TclError: pass return "break"
def __init__(self, parent): Menu.__init__(self, parent) self.parent = parent self.newmenu = Menu(self) self.showmenu = Menu(self) self.newmenu.add_command(label="NPC", command=self.parent.onNew) self.newmenu.add_separator() self.newmenu.add_command(label="Save", command=self.parent.save) self.newmenu.add_command(label="Load", command=self.parent.load) self.showmenu.add_command(label="Info", command=self.parent.get_info) self.newmenu.add_separator() self.showmenu.add_separator() self.add_cascade(label="New", menu=self.newmenu) self.add_cascade(label="Show", menu=self.showmenu) self.add_command(label="Exit", command=self.parent.quit)
class MyGUI(Frame): def __init__(self, parent=None): Frame.__init__(self,parent) self.parent = parent self.parent.title("Accounting") self.status = StatusBar(parent) self.status.set("%s","...") self.status.pack(side=BOTTOM, fill=BOTH) self.leftmenu = LeftMenu(parent) self.leftmenu.pack(side=LEFT, fill=BOTH) self.paymentframe = Frame(self,relief=GROOVE, bd=1) Label(self.paymentframe,text="Упорядочить по",height=2).grid(row=0,column=0,columnspan=2) self.paymentframe.pack(side=TOP,fill=BOTH,expand=YES) self.menubar = Menu(self) menu = Menu(self.menubar, tearoff=0) self.menubar.add_cascade(label="File", menu=menu) menu.add_command(label="LogIn", command=(lambda: authWindow(self))) menu.add_separator() menu.add_command(label="MessBox",command=(lambda: self.addPayment())) menu.add_separator() menu.add_command(label="Close", command=self.quit) menu = Menu(self.menubar, tearoff=0) self.menubar.add_cascade(label="Other", menu=menu) menu.add_command(label="Статистика", command=(lambda: Statistics(self))) menu.add_command(label="Copy") menu.add_command(label="Paste") try: self.master.config(menu=self.menubar) except AttributeError: # master is a toplevel window (Python 1.4/Tkinter 1.63) self.master.tk.call(master, "config", "-menu", self.menubar) self.pack() def addPayment(self): pass def reply(self,text): messagebox.showinfo(title='popup', message=user.name)
def __init__(self, master=None): Menu.__init__(self) self = Menu(master) filemenu = Menu(self, tearoff=False) filemenu.add_command(label="Open") self.add_cascade(menu=filemenu, label="File") windowmenu = Menu(self, name="window", tearoff=False) self.add_cascade(menu=windowmenu, label="Window") helpmenu = Menu(self, name="help", tearoff=False) self.add_cascade(menu=helpmenu, label="Help") master['menu'] = self
def __init__(self, master, restore_project=False, **kw): Frame.__init__(self, master, **kw) #Load a project if restore_project: self.project = templify.Project.load(filedialog.askopenfilename()) else: self.project = templify.Project(sample_file=filedialog.askopenfilename()) #Text self.text = Text(self) self.init_text() #Scrollbars self.vertical_scrollbar = ttk.Scrollbar(self) self.horizontal_scrollbar = ttk.Scrollbar(self) self.init_scrollbars() #Pop-up menu self.pop_up_menu = Menu(self) self.init_pop_up_menu() #Layout management self.grid_conf() #Binding management self.master.bind('<Control-s>', lambda e:self.project.save()) self.master.bind('<3>', lambda e: self.pop_up_menu.post(e.x_root, e.y_root))
def __init__(self, root, change_hook = None, highlighter = None, grammar=None): ScrolledText2.__init__(self,root,change_hook) # Non-wrapping, no border, undo turned on, max undo 50 self.text = self # For the methods taken from IDLE self.root = root self.change_hook = change_hook self.characters = ascii_letters + digits + punctuation self.tabwidth = 8 # for IDLE use, must remain 8 until Tk is fixed self.indentwidth = 4 self.indention = 0 # The current indention level self.set_tabwidth(self.indentwidth) # IDLE... self.previous_line = "0" self.highlighter = None # create a popup menu self.menu = Menu(root, tearoff=0) self.menu.add_command(label="Undo", command=self.edit_undo) self.menu.add_command(label="Redo", command=self.edit_redo) #self.menu.add_command(type="separator") self.menu.add_command(label="Cut", command=self.cut) self.menu.add_command(label="Copy", command=self.copy) self.menu.add_command(label="Paste", command=self.paste) self.bind('<KeyRelease>', self.key_release) # For scanning input self.bind('<Return>',self.autoindent) # Overides default binding #self.bind('<Tab>',self.autoindent) # increments self.indention #self.bind('<BackSpace>',self.autoindent) # decrements self.indention self.bind('<Button-3>', self.popup) # right mouse button opens popup self.bind('<Button-1>', self.recolorCurrentLine) # left mouse can reposition cursor, so recolor (e.g. bracket highlighting necessary) self.bind('<Control-Any-KeyPress>', self.ctrl) self.grammar = grammar self.setHighlighter(highlighter)
def create_context_menus(self): """Creates the connects menus, i.e. for right click""" self.context = Menu(self.master, tearoff=0) self.context.add_command(label="Dirty", command=self.control.cmd_dirty) self.context.add_command(label="Clean", command=self.control.cmd_clean)
def __init__(self, parent): Frame.__init__(self, parent) if not os.path.exists(self.WORK_FILE): os.makedirs(self.WORK_DIR) self.simulateReboot(True) self.parent = parent menu = Menu(self.parent) menu1 = Menu(menu,tearoff=0) menu1.add_command(label="Simulate Reboot",command=self.simulateReboot) menu1.add_separator() menu1.add_command(label="Quit!", command=self.parent.quit) menu.add_cascade(label="Menu",menu=menu1) # display the menu self.parent.config(menu=menu) self.parent.title("GPIOSim") self.pack(fill=BOTH, expand=1) self.canvas = None self.canvas = Canvas(self, bg=self.BG_COLOR) #self.canvas.bind("<Button-1>",self.click) #Images (gif base64 encoded) imgInLeft = "R0lGODlhHgASAOf7AAoMCAITBBcQCAYbAAsaEBUYEBEaCRMeCB0ZIREhGRkhFB0gEyMmGiIpFy8mNTQyNiROCCJZACxYCTlUKzpWGyleADBeBjRdGCxiCShlAEFcM0BeKDJmAzpmBCFwADxlIBt1BC9yBGpZW0NpMTtvDzttKkdqPid8AENxHD12DDh5AE9tPEZyJUV2Lzh/AF5rYD5+CEV+Fz+AGFxzT1h4LUx9NUaEAkCGA2dxYUqC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+f/+4fX/+v78//j+///+7//+9f3//CH+EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAHgASAAAI/gCjCcpESRAgQ82MUcJDiFKlQOM6acpkp9KkT/Lu7fOHb5++d4tazIhTBowRXHViaAEzxQglYzyMTKmzhUYlffs26uPn79ydLbyYIdMSyJcSPcikuYJhSliOPsykbUoyy94+fvXY7cs3LkgZaMuARfmTrAYfZdpi0QiFC4YqacUayaBWb9+/f/T+scsmI8+zaqtmWOrFglS3Z5FQoHpFAhg3Z3RKhOs3758/fpZlFebWTVWKWq9S0OKGrc6NWn+IeErFqIgPcxr9Xd0XD1EOWN22EVqhq00SXsBcUXEyKwkST57wxECjjt/Vuv/aoYkx7Ju3Lyt2HRnCB9MgGnJa/onYEumSHhKO5OHFtxMfOiFmnh1jhOSILR1GLvV5g35WhzOMHBKZKRr9I88+7phzAhKF4AEIC3KMsoEWjEQSRwa2wMFDGIMw4oUDxFylzz/4rCMFDHp4UQgSHwTzAXd8rAHDI4mcAEUcfpzRASo5jfhPPU2I8AUbeBQxQS42LPEGHl8kgQMrKjwxxxterNDFO3nhgw8/kmiwhRtrDKEBJ4ls8AUZYSwRQik97BBHHGqIAIQ6svGDjzu3mBlGFk9swIkiFGThRRhaVCCKGCKEwcYWLLgAzj7w/MPPPddYUAQUVXjBwR6QTDCEFWpMsQArY4BQRKZKVDCNbB7xQw4GaDyAocUPL3QhSQVFIBFGERCAksYHslqBhQOn6MMqP+uYsMETRgyRgwRXjFADFkbQoIEHiiSwRBFFEOEAE/f8c0+4//wSQQQPHIAAAg80MIAAAAwQAAENGEAAAwUowMAF1ohTTjnphBsQADs=" self.phInLeft = PhotoImage(data=bytes(imgInLeft, 'latin1')) self.phInRight = PhotoImage(data=bytes(imgInRight, 'latin1')) self.phOutLeft = PhotoImage(data=bytes(imgOutLeft, 'latin1')) self.phOutRight = PhotoImage(data=bytes(imgOutRight, 'latin1')) self.updateUI()
def viewRenderedGrid(modelXbrl, tabWin, lang=None): modelXbrl.modelManager.showStatus(_("viewing rendering")) view = ViewRenderedGrid(modelXbrl, tabWin, lang) # dimension defaults required in advance of validation from arelle import ValidateXbrlDimensions ValidateXbrlDimensions.loadDimensionDefaults(view) # context menu setDefaults(view) menu = view.contextMenu() optionsMenu = Menu(view.viewFrame, tearoff=0) view.ignoreDimValidity.trace("w", view.viewReloadDueToMenuAction) optionsMenu.add_checkbutton(label=_("Ignore Dimensional Validity"), underline=0, variable=view.ignoreDimValidity, onvalue=True, offvalue=False) view.xAxisChildrenFirst.trace("w", view.viewReloadDueToMenuAction) optionsMenu.add_checkbutton(label=_("X-Axis Children First"), underline=0, variable=view.xAxisChildrenFirst, onvalue=True, offvalue=False) view.yAxisChildrenFirst.trace("w", view.viewReloadDueToMenuAction) optionsMenu.add_checkbutton(label=_("Y-Axis Children First"), underline=0, variable=view.yAxisChildrenFirst, onvalue=True, offvalue=False) menu.add_cascade(label=_("Options"), menu=optionsMenu, underline=0) view.tablesMenu = Menu(view.viewFrame, tearoff=0) menu.add_cascade(label=_("Tables"), menu=view.tablesMenu, underline=0) view.tablesMenuLength = 0 view.menuAddLangs() view.menu.add_command(label=_("Save html file"), underline=0, command=lambda: view.modelXbrl.modelManager.cntlr.fileSave(view=view)) view.view() view.blockSelectEvent = 1 view.blockViewModelObject = 0 view.viewFrame.bind("<Enter>", view.cellEnter, '+') view.viewFrame.bind("<Leave>", view.cellLeave, '+')
def __initUI(self): """ Set up UI. """ self.pack(fill=BOTH, expand=1) # notebook for LpoView tabs self.__notebook = Notebook(self) self.__notebook.pack(fill=BOTH, expand=1) # menu bar with file menu self.__menubar = Menu(self.__parent) self.__parent.config(menu=self.__menubar) self.__filemenu = Menu(self.__menubar, tearoff=0) self.__filemenu.add_command(label="Open", command=self.__onOpen) self.__filemenu.add_command(label="Close", command=self.__onClose) self.__filemenu.add_command(label="Exit", command=self.__onExit) self.__menubar.add_cascade(label="File", menu=self.__filemenu) # size and title self.__parent.geometry("300x300+300+300") self.__parent.title("Lpo viewer Tk")
def initUI(self): self.master.title("Popup menu") self.menu = Menu(self.master, tearoff=0) self.menu.add_command(label="Beep", command=self.bell) self.menu.add_command(label="Exit", command=self.onExit) self.master.bind("<Button-3>", self.showMenu) self.pack()
def create_menu(self): menubar = Menu(self) filemenu = Menu(menubar) self.config(menu=menubar)
def createWidgets(self): # Tab Control introduced here -------------------------------------- tabControl = ttk.Notebook(self.win) # Create Tab Control tab1 = ttk.Frame(tabControl) # Create a tab tabControl.add(tab1, text='MySQL') # Add the tab tab2 = ttk.Frame(tabControl) # Add a second tab tabControl.add(tab2, text='Widgets') # Make second tab visible tabControl.pack(expand=1, fill="both") # Pack to make visible # ~ Tab Control introduced here ----------------------------------------- # We are creating a container frame to hold all other widgets self.mySQL = ttk.LabelFrame(tab1, text=' Python Database ') self.mySQL.grid(column=0, row=0, padx=8, pady=4) # Creating a Label ttk.Label(self.mySQL, text="Book Title:").grid(column=0, row=0, sticky='W') # Adding a Textbox Entry widget book = tk.StringVar() self.bookTitle = ttk.Entry(self.mySQL, width=34, textvariable=book) self.bookTitle.grid(column=0, row=1, sticky='W') # Adding a Textbox Entry widget book1 = tk.StringVar() self.bookTitle1 = ttk.Entry(self.mySQL, width=34, textvariable=book1) self.bookTitle1.grid(column=0, row=2, sticky='W') # Adding a Textbox Entry widget book2 = tk.StringVar() self.bookTitle2 = ttk.Entry(self.mySQL, width=34, textvariable=book2) self.bookTitle2.grid(column=0, row=3, sticky='W') # Creating a Label ttk.Label(self.mySQL, text="Page:").grid(column=1, row=0, sticky='W') # Adding a Textbox Entry widget page = tk.StringVar() self.pageNumber = ttk.Entry(self.mySQL, width=6, textvariable=page) self.pageNumber.grid(column=1, row=1, sticky='W') # Adding a Textbox Entry widget page = tk.StringVar() self.pageNumber1 = ttk.Entry(self.mySQL, width=6, textvariable=page) self.pageNumber1.grid(column=1, row=2, sticky='W') # Adding a Textbox Entry widget page = tk.StringVar() self.pageNumber2 = ttk.Entry(self.mySQL, width=6, textvariable=page) self.pageNumber2.grid(column=1, row=3, sticky='W') # Adding a Button self.action = ttk.Button(self.mySQL, text="Insert Quote", command=self.insertQuote) self.action.grid(column=2, row=1) # Adding a Button self.action1 = ttk.Button(self.mySQL, text="Get Quotes", command=self.getQuote) self.action1.grid(column=2, row=2) # Adding a Button self.action2 = ttk.Button(self.mySQL, text="Mody Quote", command=self.modifyQuote) self.action2.grid(column=2, row=3) # Add some space around each widget for child in self.mySQL.winfo_children(): child.grid_configure(padx=2, pady=4) quoteFrame = ttk.LabelFrame(tab1, text=' Book Quotation ') quoteFrame.grid(column=0, row=1, padx=8, pady=4) # Using a scrolled Text control quoteW = 40 quoteH = 6 self.quote = scrolledtext.ScrolledText(quoteFrame, width=quoteW, height=quoteH, wrap=tk.WORD) self.quote.grid(column=0, row=8, sticky='WE', columnspan=3) # Add some space around each widget for child in quoteFrame.winfo_children(): child.grid_configure(padx=2, pady=4) #====================================================================================================== # Tab Control 2 #====================================================================================================== # We are creating a container frame to hold all other widgets -- Tab2 self.mySQL2 = ttk.LabelFrame(tab2, text=WIDGET_LABEL) self.mySQL2.grid(column=0, row=0, padx=8, pady=4) # Creating three checkbuttons self.chVarDis = tk.IntVar() self.check1 = tk.Checkbutton(self.mySQL2, text="Disabled", variable=self.chVarDis, state='disabled') self.check1.select() self.check1.grid(column=0, row=0, sticky=tk.W) self.chVarUn = tk.IntVar() self.check2 = tk.Checkbutton(self.mySQL2, text="UnChecked", variable=self.chVarUn) self.check2.deselect() self.check2.grid(column=1, row=0, sticky=tk.W) self.chVarEn = tk.IntVar() self.check3 = tk.Checkbutton(self.mySQL2, text="Toggle", variable=self.chVarEn) self.check3.deselect() self.check3.grid(column=2, row=0, sticky=tk.W) # trace the state of the two checkbuttons self.chVarUn.trace( 'w', lambda unused0, unused1, unused2: self.checkCallback()) self.chVarEn.trace( 'w', lambda unused0, unused1, unused2: self.checkCallback()) # Radiobutton list colors = ["Blue", "Gold", "Red"] self.radVar = tk.IntVar() # Selecting a non-existing index value for radVar self.radVar.set(99) # Creating all three Radiobutton widgets within one loop for col in range(3): curRad = 'rad' + str(col) curRad = tk.Radiobutton(self.mySQL2, text=colors[col], variable=self.radVar, value=col, command=self.radCall) curRad.grid(column=col, row=6, sticky=tk.W, columnspan=3) # Create a container to hold labels labelsFrame = ttk.LabelFrame(self.mySQL2, text=' Labels within a Frame ') labelsFrame.grid(column=0, row=7, pady=6) # Place labels into the container element - vertically ttk.Label(labelsFrame, text="Choose a number:").grid(column=0, row=0) ttk.Label(labelsFrame, text="Label 2").grid(column=0, row=1) # Add some space around each label for child in labelsFrame.winfo_children(): child.grid_configure(padx=6, pady=1) number = tk.StringVar() self.combo = ttk.Combobox(self.mySQL2, width=12, textvariable=number) self.combo['values'] = (1, 2, 4, 42, 100) self.combo.grid(column=1, row=7, sticky=tk.W) self.combo.current(0) self.combo.bind('<<ComboboxSelected>>', self._combo) # Adding a Spinbox widget using a set of values self.spin = Spinbox(self.mySQL2, values=(1, 2, 4, 42, 100), width=5, bd=8, command=self._spin) self.spin.grid(column=2, row=7, sticky='W,', padx=6, pady=1) # Using a scrolled Text control scrolW = 40 scrolH = 1 self.scr = scrolledtext.ScrolledText(self.mySQL2, width=scrolW, height=scrolH, wrap=tk.WORD) self.scr.grid(column=0, row=8, sticky='WE', columnspan=3) # Create Manage Files Frame ------------------------------------------------ mngFilesFrame = ttk.LabelFrame(tab2, text=' Manage Files: ') mngFilesFrame.grid(column=0, row=1, sticky='WE', padx=10, pady=5) # Button Callback def getFileName(): print('hello from getFileName') fDir = path.dirname(__file__) fName = fd.askopenfilename(parent=self.win, initialdir=fDir) print(fName) self.fileEntry.config(state='enabled') self.fileEntry.delete(0, tk.END) self.fileEntry.insert(0, fName) if len(fName) > self.entryLen: self.fileEntry.config(width=len(fName) + 3) # Add Widgets to Manage Files Frame lb = ttk.Button(mngFilesFrame, text="Browse to File...", command=getFileName) lb.grid(column=0, row=0, sticky=tk.W) #----------------------------------------------------- file = tk.StringVar() self.entryLen = scrolW - 4 self.fileEntry = ttk.Entry(mngFilesFrame, width=self.entryLen, textvariable=file) self.fileEntry.grid(column=1, row=0, sticky=tk.W) #----------------------------------------------------- logDir = tk.StringVar() self.netwEntry = ttk.Entry(mngFilesFrame, width=self.entryLen, textvariable=logDir) self.netwEntry.grid(column=1, row=1, sticky=tk.W) def copyFile(): import shutil src = self.fileEntry.get() file = src.split('/')[-1] dst = self.netwEntry.get() + '\\' + file try: shutil.copy(src, dst) mBox.showinfo('Copy File to Network', 'Succes: File copied.') except FileNotFoundError as err: mBox.showerror('Copy File to Network', '*** Failed to copy file! ***\n\n' + str(err)) except Exception as ex: mBox.showerror('Copy File to Network', '*** Failed to copy file! ***\n\n' + str(ex)) cb = ttk.Button(mngFilesFrame, text="Copy File To : ", command=copyFile) cb.grid(column=0, row=1, sticky=tk.E) # Add some space around each label for child in mngFilesFrame.winfo_children(): child.grid_configure(padx=6, pady=6) # Creating a Menu Bar ========================================================== menuBar = Menu(tab1) self.win.config(menu=menuBar) # Add menu items fileMenu = Menu(menuBar, tearoff=0) fileMenu.add_command(label="New") fileMenu.add_separator() fileMenu.add_command(label="Exit", command=self._quit) menuBar.add_cascade(label="File", menu=fileMenu) # Add another Menu to the Menu Bar and an item helpMenu = Menu(menuBar, tearoff=0) helpMenu.add_command(label="About") menuBar.add_cascade(label="Help", menu=helpMenu) # Using tkinter Variable Classes strData = tk.StringVar() strData.set('Hello StringVar') # It is not necessary to create a tk.StringVar() strData = tk.StringVar() strData = self.spin.get() # Place cursor into name Entry self.bookTitle.focus()
short_term_mem["convo"].append(user_response) if (user_response != ''): if (user_response == 'exit' or user_response == 'quit'): print('NANOSEC TIME STOP: ', time.thread_time_ns() / 1000000000) else: print('\n', end=" ") responsive = (response(user_response)) print(responsive + '\n') sent_tokens.remove(user_response) rejuvinate(1) return responsive #MENU------------------------------------- master_splinter = tk menu = Menu(master_splinter, fg="white") menu.config(bg="black") master_splinter.config(menu=menu) filemenu = Menu(menu) journalMenu = Menu(menu) menu.add_cascade(label="Think", menu=filemenu) #editMenu = Menu(menu) #editMenu.add_command(label="Universe Message", command=donothing) #editMenu.add_command(label="Manifest", command=donothing) #menu.add_cascade(label="Feeling", menu=editMenu) filemenu.add_command(label="Save", command=save) filemenu.add_command(label="about", command=about) filemenu.add_command(label="Close", command=tk.destroy) journalMenu.add_command(label="Launch AI Journal", command=journal) menu.add_cascade(label="My Journal", menu=journalMenu)
# start of script logging.basicConfig(filename=logging_file, level=logging.INFO, format="%(asctime)s %(message)s") # set up gui root = Tk() root.title('Endobase Data Entry') root.geometry('320x190+900+400') root.option_add('*tearOff', FALSE) 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) menubar = Menu(root) root.config(menu=menubar) # win['menu'] = menubar menu_extras = Menu(menubar) # menu_edit = Menu(menubar) menubar.add_cascade(menu=menu_extras, label='Extras') menu_extras.add_command(label='Roster', command=open_roster) # menu_extras.add_command(label='Web Page', command=open_today) endo = StringVar() anaes = StringVar() mrn = StringVar() proc = StringVar() type_of_procedures = defaultdict(list)
def exit(): MsgBox = messagebox.askquestion( 'Exit Application', 'Are you sure you want to exit the application', icon='warning') if MsgBox == 'yes': window.destroy() window = Tk() window.title("Welcome to EMI Loan Calculator") p1 = PhotoImage(file='login.png') window.iconphoto(False, p1) chooser = Menu() item1 = Menu(tearoff=0) item1.add_command(label='Profile Account Detail', command=profileaccount) item1.add_command(label='Profile Personal Detail', command=profilepersonal) #item1.add_separator() #item1.add_command(label='Help') item2 = Menu(tearoff=0) item2.add_command(label='User Account Detail', command=useraccount) item2.add_command(label='User Personal Detail', command=userpersonal) item3 = Menu(tearoff=0) item3.add_command(label='Client Personal Detail', command=clientpersonal) item3.add_command(label='Client Professional Detail', command=clientprofesional) item3.add_command(label='Client Responsibility Detail',
win.quit() win.destroy() exit() #====================== # procedural code #====================== # Create instance win = tk.Tk() # Add a title win.title("Python Projects") # --------------------------------------------------------------- # Creating a Menu Bar menuBar = Menu() win.config(menu=menuBar) # Add menu items fileMenu = Menu(menuBar, tearoff=0) fileMenu.add_command(label="New") fileMenu.add_separator() fileMenu.add_command(label="Exit", command=_quit) menuBar.add_cascade(label="File", menu=fileMenu) # Add another Menu to the Menu Bar and an item helpMenu = Menu(menuBar, tearoff=0) helpMenu.add_command(label="About") menuBar.add_cascade(label="Help", menu=helpMenu) # ---------------------------------------------------------------
calledEvent = root.call(event.widget, "index", "active") print(calledEvent) if (calledEvent == 0): updateSB("Open a file") elif (calledEvent == 2): updateSB("Exit the program") elif (calledEvent == "none"): updateSB("") ##### MENU BAR GUI ##### palette_editor = PaletteEditor() # Config to set mainMenuBar as the menu bar mainMenuBar = Menu(root) root.config(menu=mainMenuBar) # Create object for the File dropdown bar, tearoff=0 removes the dashes at the top of the cascade menu mainFileDropDown = Menu(mainMenuBar, tearoff=0) # Add the File cascade to the mainMenuBar mainMenuBar.add_cascade(label="File", menu=mainFileDropDown) # Add Options to the mainFileDropDown Cascade mainFileDropDown.add_command(label="Open", command=palette_editor.openFileCmd) mainFileDropDown.add_separator() mainFileDropDown.add_command(label="Quit", command=root.quit) # Bind MouseOver events mainFileDropDown.bind("<<MenuSelect>>", mOver_File)
class PybraryGUI(): def __init__(self): # create window self.window = tk.Tk() self.window.title("Pybrary") self.window.minsize(width=600, height=600) def setupGUI(self): self.setupMenu() self.setupTabs() self.setupWidgets() def setupMenu(self): print("Creating Menus...") # Create menu bar self.menu_bar = Menu(self.window) self.window.config(menu=self.menu_bar) # Create menus per menus.xml file menulist = configRoot.findall('menubar/menu') for m in menulist: menu = Menu(self.menu_bar, tearoff=0) itemlist = m.findall('item') for i in itemlist: callback = getattr(self, i[0].text) menu.add_command(label=i.attrib['label'], command=callback) self.menu_bar.add_cascade(label=m.attrib['label'], menu=menu) def setupTabs(self): print("Setting up tabs") self.tabControl = ttk.Notebook(self.window) tablist = configRoot.findall('tablist/tab') self.tabRefList = [] for t in tablist: tab = ttk.Frame(self.tabControl) self.tabRefList.append(tab) self.tabControl.add(tab, text=t.attrib['label']) self.tabControl.pack(expand=True, fill=tk.BOTH) def setupWidgets(self): self.setupTreeView() def setupTreeView(self): #probably want treeview, not listbox scr_w = 180 scr_h = 10 tabConfig = configRoot.findall('treeview/tab') self.tabLabelList = [] self.headingDict = {} for t in tabConfig: tabName = t.attrib['label'] self.tabLabelList.append(tabName) headingConfig = t.findall('heading') temp = [] for h in headingConfig: temp.append(h.attrib['label']) self.headingDict[tabName] = temp.copy() temp.clear() print(self.headingDict) for tab in self.tabControl.winfo_children(): # listbox = Listbox(tab, width = 120) # listbox.grid(column = 0, row = 0, padx = 20, pady = 10) tabText = self.tabControl.tab(tab)['text'] treeview = Treeview(tab) #treeview['columns'] = ('Title', 'Author', 'Platform') treeview['columns'] = self.headingDict[tabText] treeview.heading("#0", text="ID") treeview.column('#0', minwidth=50, width=50, stretch=False) for h in treeview['columns']: print(h) treeview.heading(h, text=h) treeview.grid( column=0, row=0, sticky="NSEW", ) treeview.bind("<Double-1>", self.itemSelected) treeview.config(height=25) scrollbar = Scrollbar(tab) scrollbar.grid(column=1, row=0, sticky="NS") treeview.config(yscrollcommand=scrollbar.set) scrollbar.config(command=treeview.yview) #treeCol = self.tabRefList[0].winfo_children()[0].column('#0', minwidth=50, width=50, stretch=False) def itemSelected(self, event): print(event.widget) #item = self.tabRefList[0].winfo_children()[0].selection() item = event.widget.selection() value = event.widget.item(item, "values") #msg.showinfo("Item Selected", "Title: {0}\nAuthor: {1}\nPlatform: {2} ".format(value[0], value[1], value[2])) import websearch websearch.google(value[0]) def newItem(self): print("New item") def _quit(self): print("Quitting") self.window.quit() self.window.destroy() exit()
def create_menu(): menubar = Menu(root) optionsmenu = Menu(menubar, tearoff=0) optionsmenu.add_command(label="Settings", command=open_settings) optionsmenu.add_separator() optionsmenu.add_command(label="Exit", command=confirm_quit) menubar.add_cascade(label="Options", menu=optionsmenu) menubar.add_cascade(label="About", command=about) return menubar
def initUI(self): self.master.title("AzmuthStar") #*****MENUBAR*****# #FILE menubar = Menu(self.master) self.master.bind('<Control-q>', quit) self.fileMenu = Menu(self.master, tearoff=0) self.fileMenu.add_command(label="Open Product...", command=self.openpro) self.fileMenu.add_command(label="Save", command=self.savepro) # self.fileMenu.add_command(label="Save As", command="") self.fileMenu.add_separator() self.fileMenu.add_command(label="Exit 'Ctrl+Q'", command=self.onExit) menubar.add_cascade(label="File", menu=self.fileMenu) #Tools self.filterMenu = Menu(self.master, tearoff=0) self.filterMenu.add_command(label="Speckle Filtering", command="") #self.editMenu.add_separator() menubar.add_cascade(label="Tools", menu=self.filterMenu) #View self.editMenu = Menu(self.master, tearoff=0) self.editMenu.add_command(label="Cut", command="") self.editMenu.add_command(label="Copy", command="") self.editMenu.add_command(label="Paste", command="") self.editMenu.add_separator() self.editMenu.add_command(label="Delete", command="") menubar.add_cascade(label="View", menu=self.editMenu) #Help self.helpMenu = Menu(self.master, tearoff=0) self.helpMenu.add_command(label="About", command=self.about) #self.helpMenu.add_separator() menubar.add_cascade(label="Help", menu=self.helpMenu) #*****Toolbar*****# toolbar = Frame(self.master, bd=1, relief=RAISED) #Open self.img = Image.open("img\\folder.png") openimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=openimg, relief=FLAT, command=self.openpro) openButton.image = openimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Save self.img = Image.open("img\\save.png") saveimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=saveimg, relief=FLAT, command=self.savepro) openButton.image = saveimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Download self.img = Image.open("img\\download.png") downimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=downimg, relief=FLAT, command=self.down_window) openButton.image = downimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Discrimination self.img = Image.open("img\\scissor.png") cutimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=cutimg, relief=FLAT, command=self.land_water_descrimination) openButton.image = cutimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Detection self.img = Image.open("img\\search.png") searchimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=searchimg, relief=FLAT, command=self.browsetrainFiles) openButton.image = searchimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Map self.img = Image.open("img\\location.png") Mapimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=Mapimg, relief=FLAT, command=self.showmap) openButton.image = Mapimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Exit self.img = Image.open("img\\exit.png") eimg = ImageTk.PhotoImage(self.img) exitButton = Button(toolbar, image=eimg, relief=FLAT, command=self.quit) exitButton.image = eimg exitButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack()
class AzmuthStar(Frame): def __init__(self): super().__init__() self.initUI() def initUI(self): self.master.title("AzmuthStar") #*****MENUBAR*****# #FILE menubar = Menu(self.master) self.master.bind('<Control-q>', quit) self.fileMenu = Menu(self.master, tearoff=0) self.fileMenu.add_command(label="Open Product...", command=self.openpro) self.fileMenu.add_command(label="Save", command=self.savepro) # self.fileMenu.add_command(label="Save As", command="") self.fileMenu.add_separator() self.fileMenu.add_command(label="Exit 'Ctrl+Q'", command=self.onExit) menubar.add_cascade(label="File", menu=self.fileMenu) #Tools self.filterMenu = Menu(self.master, tearoff=0) self.filterMenu.add_command(label="Speckle Filtering", command="") #self.editMenu.add_separator() menubar.add_cascade(label="Tools", menu=self.filterMenu) #View self.editMenu = Menu(self.master, tearoff=0) self.editMenu.add_command(label="Cut", command="") self.editMenu.add_command(label="Copy", command="") self.editMenu.add_command(label="Paste", command="") self.editMenu.add_separator() self.editMenu.add_command(label="Delete", command="") menubar.add_cascade(label="View", menu=self.editMenu) #Help self.helpMenu = Menu(self.master, tearoff=0) self.helpMenu.add_command(label="About", command=self.about) #self.helpMenu.add_separator() menubar.add_cascade(label="Help", menu=self.helpMenu) #*****Toolbar*****# toolbar = Frame(self.master, bd=1, relief=RAISED) #Open self.img = Image.open("img\\folder.png") openimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=openimg, relief=FLAT, command=self.openpro) openButton.image = openimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Save self.img = Image.open("img\\save.png") saveimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=saveimg, relief=FLAT, command=self.savepro) openButton.image = saveimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Download self.img = Image.open("img\\download.png") downimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=downimg, relief=FLAT, command=self.down_window) openButton.image = downimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Discrimination self.img = Image.open("img\\scissor.png") cutimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=cutimg, relief=FLAT, command=self.land_water_descrimination) openButton.image = cutimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Detection self.img = Image.open("img\\search.png") searchimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=searchimg, relief=FLAT, command=self.browsetrainFiles) openButton.image = searchimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Map self.img = Image.open("img\\location.png") Mapimg = ImageTk.PhotoImage(self.img) openButton = Button(toolbar, image=Mapimg, relief=FLAT, command=self.showmap) openButton.image = Mapimg openButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() #Exit self.img = Image.open("img\\exit.png") eimg = ImageTk.PhotoImage(self.img) exitButton = Button(toolbar, image=eimg, relief=FLAT, command=self.quit) exitButton.image = eimg exitButton.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) self.master.config(menu=menubar) self.pack() def onExit(self): self.quit() def openpro(self): currdir = os.getcwd() files = [('JPG (.jpg)', '*.jpg'), ('PNG (.png)', '*.png'), ('TIFF (.tiff)', '*.tiff')] self.file = filedialog.askopenfilename(initialdir=currdir, title="Open Product", filetypes=files, defaultextension=files) def savepro(self): currdir = os.getcwd() files = [('JPG (.jpg)', '*.jpg'), ('PNG (.png)', '*.png'), ('TIFF (.tiff)', '*.tiff')] self.file = asksaveasfile(initialdir=currdir, filetypes=files, title="Save Product", defaultextension=files) def about(self): messagebox.showinfo('About', 'Created By Team AzmuthStar.') def sentineldown(self): os.system('sentinelsat.py') def outputfolder(self): import subprocess subprocess.Popen('explorer "Processes\\Download\\Unzip\\"') #TopLevel Download window buttons def down_window(self): self.window = Toplevel(self.master) self.window.geometry('320x100') self.window.iconphoto(False, PhotoImage(file='img\\download.png')) self.window.title("Copernicus Open Access Hub") self.label_username = Label(self.window, text="Username") self.label_password = Label(self.window, text="Password") self.label_product_id = Label(self.window, text="Product ID") self.entry_username = Entry(self.window) self.entry_password = Entry(self.window, show="*") self.entry_product_id = Entry(self.window) self.label_username.grid(row=2, column=1, sticky=E) self.label_password.grid(row=3, column=1, sticky=E) self.label_product_id.grid(row=4, column=1, sticky=E) self.entry_username.grid(row=2, column=2) self.entry_password.grid(row=3, column=2) self.entry_product_id.grid(row=4, column=2) self.downbtn = Button(self.window, text="Download", command=self._down_btn_clicked) #self.button = Button(self.window, text="Download", command=lambda:[self.savepro(), self.sentinelsat()]) self.downbtn.place(bordermode=OUTSIDE, relx=0.1, rely=0.7) self.unzip = Button(self.window, text="Unzip", command=self.zip) self.unzip.place(bordermode=OUTSIDE, relx=0.3, rely=0.7) self.outFile = Button(self.window, text="Output Folder", command=self.outputfolder) self.outFile.place(bordermode=OUTSIDE, relx=0.5, rely=0.7) def zip(self): files = [('ZIP (.zip)', '*.zip'), ('RAR (.rar)', '*.rar')] self.file_name = filedialog.askopenfilename( initialdir="Processes\\Download\\", title="Select Zip file", filetypes=files, defaultextension=files) with zipfile.ZipFile(self.file_name, 'r') as file: # printing all the information of archive file contents using 'printdir' method print(file.printdir()) # extracting the files using 'extracall' method print('Extracting all files...') file.extractall('Processes\\Download\\Unzip') print('Done!!') #print('Done!') # check your directory of zip file to see the extracted files def _down_btn_clicked(self): username = self.entry_username.get() password = self.entry_password.get() product_id = self.entry_product_id.get() #print(username, password,product_id) api = SentinelAPI(username, password, 'https://scihub.copernicus.eu/dhus') print("Downloading started...") api.download(product_id) def browsetrainFiles(self): files = [('All (All)', '*.*'), ('JPG (.jpg)', '*.jpg'), ('PNG (.png)', '*.png'), ('TIFF (.tiff)', '*.tiff')] filename = filedialog.askopenfilename(initialdir="Processes\\Ocean\\", title="Select a File", filetypes=files, defaultextension=files) print(filename) file_path = filename.replace('/', '\\') print(file_path) main_detection(file_path) # cmd = 'python ' + 'single_file_testing.py' + ' ' + filename # os.system(cmd) def land_water_descrimination(self): self.window = Toplevel(self.master) self.window.geometry('300x80') self.window.iconphoto(False, PhotoImage(file='img\\scissor.png')) self.window.title("Land Water Descrimination") def water_extraction(): files = [('All (All)', '*.*'), ('TIFF (.tiff)', '*.tiff')] filename = filedialog.askopenfilename( initialdir="Processes\\Visible\\", title="Select a File", filetypes=files, defaultextension=files) src_file = filename.replace('/', '\\') Water_Extraction(src_file) def land_extraction(): files = [('All (All)', '*.*'), ('TIFF (.tiff)', '*.tiff')] filename = filedialog.askopenfilename( initialdir="Processes\\Visible\\", title="Select a File", filetypes=files, defaultextension=files) src_file = filename.replace('/', '\\') Land_Extraction(src_file) self.water = Button(self.window, text="Water Extraction", command=water_extraction) self.water.pack(pady=2) self.land = Button(self.window, text="Land Extraction", command=land_extraction) self.land.pack(pady=2) def showmap(self): os.system('python map.py')
curRad = tk.Radiobutton(mighty, text=colors[col], variable=radVar, value=col, command=radCall) curRad.grid(column=col, row=6, sticky=tk.W) # row=6 # Create a container to hold labels buttons_frame = ttk.LabelFrame(mighty, text=' Labels in a Frame ') buttons_frame.grid(column=0, row=7) # Place labels into the container element ttk.Label(buttons_frame, text="Label1").grid(column=0, row=0, sticky=tk.W) ttk.Label(buttons_frame, text="Label2").grid(column=1, row=0, sticky=tk.W) ttk.Label(buttons_frame, text="Label3").grid(column=2, row=0, sticky=tk.W) # Creating a Menu Bar menu_bar = Menu(win) win.config(menu=menu_bar) # Add menu items file_menu = Menu(menu_bar, tearoff=0) file_menu.add_command(label="New") file_menu.add_separator() file_menu.add_command(label="Exit") menu_bar.add_cascade(label="File", menu=file_menu) name_entered.focus() # Place cursor into name Entry #====================== # Start GUI #====================== win.mainloop()
def __init__(self, file=None): global root, textPad, statusText root = Tk(className="Python IDE") textPad = scrolledText.ScrolledText(root, width=80, height=20, tabs=("0.5c")) # creates text area menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu, tearoff=0) menu.add_cascade(label="File", menu=filemenu) filemenu.add_command(label="New", command=self.new_command) filemenu.add_command(label="Open...", command=self.open_command) filemenu.add_command(label="Save", command=self.save_command) filemenu.add_command(label="Save As...", command=self.saveAs_command) filemenu.add_separator() filemenu.add_command(label="Exit", command=self.exit_command) helpmenu = Menu(menu, tearoff=0) menu.add_cascade(label="Help", menu=helpmenu) helpmenu.add_command(label="About...", command=self.about_command) # end of menu creation # toolbar creation toolbar = Frame(root, bg = "grey") saveBtn = Button(toolbar, text="Save", command=self.save_command) saveBtn.pack(side=LEFT, padx=2, pady=2) compileBtn = Button(toolbar, text="Compile", command=self.compile_command) compileBtn.pack(side=LEFT, padx=2, pady=2) compileAndRunBtn = Button(toolbar, text="Compile and Run", command=self.compileRun_command) compileAndRunBtn.pack(side=LEFT, padx=2, pady=2) toolbar.pack(side=TOP, fill=X) # status bar creation statusText = StringVar() status = Label(root, text="Info", textvariable=statusText, bd=1, relief=SUNKEN, anchor=W) status.pack(side=BOTTOM, fill=X) self.linenumbers = TextLineNumbers(root, width=30) self.linenumbers.attach(textPad) self.linenumbers.pack(side="left", fill="y") textPad.bind("<KeyPress>", self.key_press) textPad.bind("<KeyRelease>", self.key_press) #root.bind("<Button>", self.key_press) textPad.vbar.bind("<Motion>", self.key_press) textPad.tag_configure("red", foreground="#ff0000") textPad.tag_configure("blue", foreground="#0000ff") textPad.tag_configure("green", foreground="#00ff00") textPad.tag_configure("black", foreground="#000000") textPad.tag_configure("purple", foreground="#800080") textPad.tag_configure("comment", foreground="#AAAAAA") text='' self.filename = file if file: with open(file, mode='rb') as f: text = f.read() textPad.delete('1.0', END) textPad.insert('1.0', text) textPad.mark_set(INSERT, '1.0') textPad.focus() self.dic = loadSyntaxHL() textPad.pack() self.compilationText = StringVar() self.compilationLabel = Label(bd=1, relief=SUNKEN, justify=LEFT) self.compilationLabel.pack(fill=X) self.executionText = StringVar() self.executionLabel = Label(bd=1, relief=SUNKEN, justify=LEFT) self.executionLabel.pack(fill=X) root.mainloop()
def init_q2k_gui(self): self.window = Tk() self.window.resizable(width=False, height=False) self.window.title("Q2K Keymap Utility") if platform.system() == 'Linux': self.window.option_add('*font', ('Liberation Sans', '-12')) self.window.geometry('490x700') if platform.system() == 'Windows': self.window.option_add('*font', ('Calibri', '-13')) self.window.geometry('496x700') menu = Menu(self.window) new_item = Menu(menu, tearoff=0) #new_item.add_command(label='Settings') #menu.add_cascade(label='File', menu=new_item) menu.add_command(label='About',command=self.show_about) self.window.config(menu=menu) # ============================================================================================================= # Tabs # ============================================================================================================= tab_control = ttk.Notebook(self.window) tab1 = ttk.Frame(tab_control) #tab2 = ttk.Frame(tab_control) tab_control.add(tab1, text='Keyplus') #tab_control.add(tab2, text='KBfirmware') # ============================================================================================================= # KEYPLUS TAB # ============================================================================================================= # Frame 1 - Combo Boxes # ============================================================================================================= # Label keyplus_lbl = Label(tab1, text= 'Convert to Keyplus YAML') keyplus_lbl.grid(column=0, row=0, sticky=W+E) # Settings top_frame = LabelFrame(tab1, text='', bd=0, padx=15, pady=2) top_frame.grid(sticky=W+E) # ============================================================================================================= # QMK Firmware Directory Entry # ============================================================================================================= # Label qmk_lbl = Label(top_frame, text='QMK Firmware Directory') # Text Box self.qmk_dir = StringVar() qmk_dir_entry = Entry(top_frame, textvariable=self.qmk_dir) # Button qmk_dir_btn = Button(top_frame, text="..", command=lambda:self.set_qmk_directory()) # ============================================================================================================= # Keyplus Output Directory Entry # ============================================================================================================= # Label keyplus_lbl = Label(top_frame, text='Output Directory') # Text Box self.keyplus_dir = StringVar() keyplus_dir_entry = Entry(top_frame, textvariable=self.keyplus_dir) # Button keyplus_dir_btn = Button(top_frame, text="..", command=lambda:self.set_keyplus_directory()) # Settings / Positioning qmk_lbl.grid (row=0, column=0, sticky=W) keyplus_lbl.grid (row=2, column=0, sticky=W) qmk_dir_entry.grid (row=1, column=0, sticky=W+E) qmk_dir_btn.grid (row=1, column=1) keyplus_dir_entry.grid(row=3, column=0, sticky=W+E) keyplus_dir_btn.grid (row=3, column=1) if platform.system() == 'Linux': qmk_dir_entry['width'] = 59 qmk_dir_btn['width'] = 2 keyplus_dir_entry['width'] = 59 keyplus_dir_btn['width'] = 2 if platform.system() == 'Windows': qmk_dir_entry['width'] = 60 qmk_dir_btn['width'] = 4 keyplus_dir_entry['width'] = 60 keyplus_dir_btn['width'] = 4 # ============================================================================================================= # Frame 2 - Combo Boxes # ============================================================================================================= kb_opts = LabelFrame(tab1, text='', bd=0, padx=15, pady=5, height=50) kb_opts.grid(sticky=E+W) # ============================================================================================================= # Dynamic Combo Boxes # | Keyboard | Rev | # | Keymap | Template | # ============================================================================================================= # Labels kb_lbl = Label(kb_opts, text='Keyboard') rev_lbl = Label(kb_opts, text='Rev') keymap_lbl = Label(kb_opts, text='Keymap') template_lbl = Label(kb_opts, text='Template') # Combo Boxes self.template = Combobox(kb_opts, state='readonly') self.keymap = Combobox(kb_opts, state='readonly') self.rev = Combobox(kb_opts, state='readonly') self.kb = Combobox(kb_opts, state='readonly') if platform.system() == 'Linux': self.template['width'] = 30 self.keymap['width'] = 30 self.rev['width'] = 30 self.kb['width'] = 30 elif platform.system() == 'Windows': self.template['width'] = 30 self.keymap['width'] = 30 self.rev['width'] = 30 self.kb['width'] = 30 self.rev.bind('<<ComboboxSelected>>', self.event_rev_selected) # Updating list triggers event rev_select self.kb.bind( '<<ComboboxSelected>>', self.event_kb_selected) # Updating list triggers event kb_select # Settings / Positioning self.kb.grid (row=1, column=0) self.rev.grid (row=1, column=1) self.keymap.grid (row=3, column=0) self.template.grid (row=3, column=1) kb_lbl.grid (row=0, column=0, sticky=W) rev_lbl.grid (row=0, column=1, sticky=W) keymap_lbl.grid (row=2, column=0, sticky=W) template_lbl.grid (row=2, column=1, sticky=W) # ============================================================================================================= # Frame 3 - Buttons # ============================================================================================================= kb_opts2 = LabelFrame(tab1, text='', bd=0, padx=15, pady=5, height=50, width=100) kb_opts2.grid(sticky=E+W) # ============================================================================================================= # Buttons: | Convert | Generate Keyboard List | Reset | # ============================================================================================================= convert_btn = Button(kb_opts2, width='10', text='Convert', command=lambda:self.btn_execute()) gen_btn = Button(kb_opts2, width='20', text='Generate Keyboard List', command=lambda:self.btn_generate_lists()) reset_btn = Button(kb_opts2, width='10', text='Reset', command=lambda:self.btn_reset()) convert_btn.grid(row=0, column=0, sticky=W+E) gen_btn.grid (row=0, column=1, padx=5, sticky=W+E) reset_btn.grid (row=0, column=2, sticky=W+E) if platform.system() == 'Linux': convert_btn['width'] = 16 gen_btn['width'] = 20 reset_btn['width'] = 16 if platform.system() == 'Windows': convert_btn['width'] = 20 gen_btn['width'] = 20 reset_btn['width'] = 20 # ============================================================================================================= # Frame 4 - Output # ============================================================================================================= console = LabelFrame(tab1, text='', bd=0, padx=15, pady=5, height=50) console.grid(sticky=W+E) # ============================================================================================================= # Console # ============================================================================================================= # Label con_lbl = Label(console, text='Console') con_lbl.grid(padx=5, row=0, column=0) # Text Box self.output = ConsoleText(console, bd=0, bg='black', fg='white') if platform.system() == 'Linux': self.output['height'] = 35 self.output['width'] = 75 self.output['font'] = ('Consolas', '9') elif platform.system() == 'Windows': self.output['height'] = 27 self.output['width'] = 65 self.output['font'] = ('Consolas', '9') self.output.grid(padx=5, row=1, column=0, sticky=W+E) # KBfirmware ''' lbl2 = Label(tab2, text= 'Convert to KBfirmware JSON') lbl2.grid(column=0, row=0) frame1_qmk_dir = LabelFrame(tab2, text=' QMK Firmware Dir: ', bd=0, padx=15, pady=2) frame1_qmk_dir.grid(sticky=E+W) qmkdir_entry = Entry(frame1_qmk_dir, textvariable=qmkdir, width=32) qmkdir_entry.grid(column=0, row=0, sticky=E+W) dir_btn = Button(frame1_qmk_dir, text="..", command=lambda:find_directory(qmkdir)) dir_btn.grid(column=1, row=0) frame2_kbf_dir = LabelFrame(tab2, text=' Output Dir: ', bd=0, padx=15, pady=2) frame2_kbf_dir.grid(sticky=E+W) kbfdir = StringVar() kbfdir_entry = Entry(frame2_kbf_dir, textvariable=kbfdir, width=32) kbfdir_entry.grid(column=0, row=0, sticky=E+W) dir_btn = Button(frame2_kbf_dir, text="..", command=lambda:find_directory(kbfdir)) dir_btn.grid(column=1, row=0) ''' #tab_control.pack(expand=1, fill='both') tab_control.grid()
class SmEditor: root = tk.Tk() __thisWidth = 500 __thisHeight = 450 __thisMenuBar = Menu(root) __thisFileMenu = Menu(__thisMenuBar, tearoff=0) __thisEditMenu = Menu(__thisMenuBar, tearoff=0) __thisHelpMenu = Menu(__thisMenuBar, tearoff=0) # __thisScrollBar = Scrollbar(text) __file = None def __init__(self): self.jsonCon = JsonController(self) self.text = tk.Text(self.root) self.text.grid() self.text.pack(side="left") self.redirector = WidgetRedirector(self.text) self.original_mark = self.redirector.register("mark", self.on_mark) self.original_insert = self.redirector.register( "insert", self.on_insert) self.original_delete = self.redirector.register( "delete", self.on_delete) self.delta_index = Cursor("1.0") self.listen_thread = Thread(target=self.jsonCon.listen) self.listen_thread.start() self.root.protocol('WM_DELETE_WINDOW', self.shutdown) # root is your root window self.ignore_actions = False self.root.title("Collaborative Notepad CS457") screenWidth = self.root.winfo_screenwidth() screenHeight = self.root.winfo_screenheight() left = (screenWidth / 2) - (self.__thisWidth / 2) top = (screenHeight / 2) - (self.__thisHeight / 2) self.root.geometry('%dx%d+%d+%d' % (self.__thisWidth, self.__thisHeight, left, top)) self.root.grid_rowconfigure(0, weight=1) self.root.grid_columnconfigure(0, weight=1) #self.text.grid(sticky=N + E + S + W) self.__thisFileMenu.add_command(label="New", command=self.__newFile) self.__thisFileMenu.add_command(label="Open", command=self.__openFile) self.__thisFileMenu.add_command(label="Save", command=self.__saveFile) self.__thisFileMenu.add_separator() self.__thisMenuBar.add_cascade(label="File", menu=self.__thisFileMenu) #self.__thisEditMenu.add_command(label="Cut",command=self.__cut) #self.__thisEditMenu.add_command(label="Copy",command=self.__copy) #self.__thisEditMenu.add_command(label="Paste",command=self.__paste) #self.__thisMenuBar.add_cascade(label="Edit",menu=self.__thisEditMenu) self.__thisHelpMenu.add_command(label="About Notepad", command=self.__showAbout) self.__thisMenuBar.add_cascade(label="Help", menu=self.__thisHelpMenu) self.root.config(menu=self.__thisMenuBar) # self.__thisScrollBar.pack(side=RIGHT, fill=Y) # self.__thisScrollBar.config(command=self.text.yview) # self.text.config(yscrollcommand=self.__thisScrollBar.set) get_text_dict = {OP: GET_ALL_TEXT} self.jsonCon.send_dict(get_text_dict) self.root.mainloop() def __showAbout(self): showinfo("Notepad", "Welcome to our collaborative notepad example") def __openFile(self): self.__file = askopenfilename(defaultextension=".txt", filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt")]) if self.__file == "": self.__file = None #no file specified else: self.root.title(os.path.basename(self.__file) + " - Notepad") self.text.delete(1.0, END) file = open(self.__file, "r") #TODO: Check this against michaels code: self.text.insert(1.0, file.read()) file.close() def __newFile(self): self.root.title("Untitled - Notepad") self.__file = None self.text.delete(1.0, END) def __saveFile(self): if self.__file == None: self.__file = asksaveasfilename(initialfile='Untitled.txt', defaultextension=".txt", filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt")]) if self.__file == "": self.__file = None else: file = open(self.__file, "w") file.write(self.text.get(1.0, END)) file.close() self.root.title(os.path.basename(self.__file) + " - Notepad") else: file = open(self.__file, "w") file.write(self.text.get(1.0, END)) file.close() def __cut(self): self.text.event_generate("<<Cut>>") def __copy(self): self.text.event_generate("<<Copy>>") def __paste(self): self.text.event_generate("<<Paste>>") def shutdown(self): print("Shutdown") self.jsonCon.send_message("QUIT") self.listen_thread.join(1) self.jsonCon.close() self.root.destroy() def compute_current_delta(self): c_delta = Cursor(self.delta_index) c_insert = Cursor(self.text.index(INSERT)) text = self.text.get(self.delta_index, INSERT) self.delta_index = self.text.index(INSERT) return text, c_delta, (c_insert - c_delta) def on_mark(self, *event): # print("mark", event) # the mark/cursor position was updated. We want to update our current cursor tracker and the delta cursor self.delta_index = Cursor(self.text.index(INSERT)) return self.original_mark(*event) def on_insert(self, *event): # print("insert", event) self.delta_index = Cursor(self.text.index(INSERT)) + Cursor("0.1") if not self.ignore_actions: self.jsonCon.propagate_insert(Cursor(self.text.index(INSERT)), event[1]) return self.original_insert(*event) def on_delete(self, *event): # Backspace index_1 = None index_2 = None if event[0] == "insert-1c": print("delete the character behind the cursor") insert_cursor = Cursor(self.text.index(INSERT)) index_1 = insert_cursor index_2 = insert_cursor - Cursor("0.1") elif event[0] == "insert": print("Delete the character before the cursor") insert_cursor = Cursor(self.text.index(INSERT)) index_1 = insert_cursor index_2 = insert_cursor + Cursor("0.1") elif event[0] == SEL_FIRST: index_1 = Cursor(self.text.index(SEL_FIRST)) index_2 = Cursor(self.text.index(SEL_LAST)) elif event[0] == 1.0: index_1 = Cursor("1.0") index_2 = Cursor(self.text.index(event[1])) if not self.ignore_actions: self.jsonCon.propagate_delete(index_1, index_2) return self.original_delete(*event) def net_insert(self, delta_index, delta): self.ignore_actions = True self.text.insert(str(delta_index), delta) self.ignore_actions = False return def net_delete(self, delta_start, delta_index2): if delta_start < delta_index2: start = delta_start end = delta_index2 else: start = delta_index2 end = delta_start # needs the greater index first self.ignore_actions = True self.text.delete(str(start), str(end)) self.ignore_actions = False return None def update_text(self, text): self.ignore_actions = True self.text.delete("1.0", END) self.text.insert("1.0", text) self.ignore_actions = False def get_text(self): return self.text.get("1.0", END)
def _create_menu(self, master): self.master.option_add('*tearOff', FALSE) calc_menu = Menu(self.master) self.master.config(menu=calc_menu) #Configuração config = Menu(calc_menu) theme = Menu(config) #Menu tema theme_incompatible = ['Default Theme For MacOS'] for t in self.settings['themes']: name = t['name'] if name in theme_incompatible: # Ignora os temas não compatíveis. continue else: theme.add_command(label=name, command=partial(self._change_theme_to, name)) #Configuração calc_menu.add_cascade(label='Configuração', menu=config) config.add_cascade(label='Tema', menu=theme) config.add_separator() config.add_command(label='Sair', command=self._exit)
def create_menu(self, root): #创建菜单栏 menu = Menu(root) #创建二级菜单 help_menu = Menu(menu, tearoff=0) help_menu.add_command(label="本系统由宁波银行绍兴分行金融科技部开发。" + "\r\n如有问题请联系运维阮金国 王立刚8831") about_menu = Menu(menu, tearoff=0) about_menu.add_command(label="version:1.0") #在菜单栏中添加以下一级菜单 menu.add_cascade(label="帮助", menu=help_menu) menu.add_cascade(label="关于", menu=about_menu) root['menu'] = menu
def create_widgets(self): tabControl = ttk.Notebook(self.win) # Create Tab Control tab1 = ttk.Frame(tabControl) # Create a tab tabControl.add(tab1, text='Tab 1') # Add the tab tab2 = ttk.Frame(tabControl) # Add a second tab tabControl.add(tab2, text='Tab 2') # Make second tab visible tabControl.pack(expand=1, fill="both") # Pack to make visible # LabelFrame using tab1 as the parent mighty = ttk.LabelFrame(tab1, text=' Mighty Python ') mighty.grid(column=0, row=0, padx=8, pady=4) # Modify adding a Label using mighty as the parent instead of win a_label = ttk.Label(mighty, text="Enter a name:") a_label.grid(column=0, row=0, sticky='W') # Adding a Textbox Entry widget self.name = tk.StringVar() name_entered = ttk.Entry(mighty, width=12, textvariable=self.name) name_entered.grid(column=0, row=1, sticky='W') # Adding a Button self.action = ttk.Button(mighty, text="Click Me!", command=self.click_me) self.action.grid(column=2, row=1) ttk.Label(mighty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() self.number_chosen = ttk.Combobox(mighty, width=12, textvariable=number, state='readonly') self.number_chosen['values'] = (1, 2, 4, 42, 100) self.number_chosen.grid(column=1, row=1) self.number_chosen.current(0) # Adding a Spinbox widget self.spin = Spinbox(mighty, values=(1, 2, 4, 42, 100), width=5, bd=9, command=self._spin) # using range self.spin.grid(column=0, row=2) # Using a scrolled Text control scrol_w = 30 scrol_h = 3 self.scrol = scrolledtext.ScrolledText(mighty, width=scrol_w, height=scrol_h, wrap=tk.WORD) self.scrol.grid(column=0, row=3, sticky='WE', columnspan=3) # Tab Control 2 ---------------------------------------------------------------------- # We are creating a container frame to hold all other widgets -- Tab2 self.mighty2 = ttk.LabelFrame(tab2, text=' The Snake ') self.mighty2.grid(column=0, row=0, padx=8, pady=4) # Creating three checkbuttons chVarDis = tk.IntVar() check1 = tk.Checkbutton(self.mighty2, text="Disabled", variable=chVarDis, state='disabled') check1.select() check1.grid(column=0, row=0, sticky=tk.W) chVarUn = tk.IntVar() check2 = tk.Checkbutton(self.mighty2, text="UnChecked", variable=chVarUn) check2.deselect() check2.grid(column=1, row=0, sticky=tk.W) chVarEn = tk.IntVar() check3 = tk.Checkbutton(self.mighty2, text="Enabled", variable=chVarEn) check3.deselect() check3.grid(column=2, row=0, sticky=tk.W) # trace the state of the two checkbuttons chVarUn.trace('w', lambda unused0, unused1, unused2 : self.checkCallback()) chVarEn.trace('w', lambda unused0, unused1, unused2 : self.checkCallback()) # First, we change our Radiobutton global variables into a list colors = ["Blue", "Gold", "Red"] # create three Radiobuttons using one variable self.radVar = tk.IntVar() # Next we are selecting a non-existing index value for radVar self.radVar.set(99) # Now we are creating all three Radiobutton widgets within one loop for col in range(3): curRad = tk.Radiobutton(self.mighty2, text=colors[col], variable=self.radVar, value=col, command=self.radCall) curRad.grid(column=col, row=1, sticky=tk.W) # row=6 # Add a Progressbar to Tab 2 self.progress_bar = ttk.Progressbar(tab2, orient='horizontal', length=286, mode='determinate') self.progress_bar.grid(column=0, row=3, pady=2) # Create a container to hold buttons buttons_frame = ttk.LabelFrame(self.mighty2, text=' ProgressBar ') buttons_frame.grid(column=0, row=2, sticky='W', columnspan=2) # Add Buttons for Progressbar commands ttk.Button(buttons_frame, text=" Run Progressbar ", command=self.run_progressbar).grid(column=0, row=0, sticky='W') ttk.Button(buttons_frame, text=" Start Progressbar ", command=self.start_progressbar).grid(column=0, row=1, sticky='W') ttk.Button(buttons_frame, text=" Stop immediately ", command=self.stop_progressbar).grid(column=0, row=2, sticky='W') ttk.Button(buttons_frame, text=" Stop after second ", command=self.progressbar_stop_after).grid(column=0, row=3, sticky='W') for child in buttons_frame.winfo_children(): child.grid_configure(padx=2, pady=2) for child in self.mighty2.winfo_children(): child.grid_configure(padx=8, pady=2) # Creating a Menu Bar menu_bar = Menu(self.win) self.win.config(menu=menu_bar) # Add menu items file_menu = Menu(menu_bar, tearoff=0) file_menu.add_command(label="New") file_menu.add_separator() file_menu.add_command(label="Exit", command=self._quit) menu_bar.add_cascade(label="File", menu=file_menu) # Display a Message Box def _msgBox(): msg.showinfo('Python Message Info Box', 'A Python GUI created using tkinter:\nThe year is 2017.') # Add another Menu to the Menu Bar and an item help_menu = Menu(menu_bar, tearoff=0) help_menu.add_command(label="About", command=_msgBox) # display messagebox when clicked menu_bar.add_cascade(label="Help", menu=help_menu) # Change the main windows icon self.win.iconbitmap('pyc.ico') # It is not necessary to create a tk.StringVar() # strData = tk.StringVar() strData = self.spin.get() print("Spinbox value: " + strData) # call function self.usingGlobal() name_entered.focus()
#라디오박스 체크박스 예쩨 나중에 필요하면 쓸것 # value1 = tk.IntVar() # check1 = tk.Checkbutton(win, text="Disabled", variable=value1, state='disabled') # Create a check button # check1.select() # check1.grid(column=0, row=3) # # value2 = tk.IntVar() # check2 = tk.Checkbutton(win, text="UnChecked", variable=value2) # Create a check button # check2.grid(column=1, row=3) # # value3 = tk.StringVar() # rad1 = tk.Radiobutton(win, text="Radio1", variable=value3, value="Clicked a Radio1.\n", command=clickRadio) # Create a radio button # rad1.select() # rad1.grid(column=2, row=3) # rad2 = tk.Radiobutton(win, text="Radio2", variable=value3, value="Clicked a Radio2.\n", command=clickRadio) # Create a radio button # rad2.grid(column=2, row=4) menuBar = Menu(win) # Create a menu win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) # Create the File Menu fileMenu.add_command(label="New") # Add the "New" menu fileMenu.add_separator() # Add a separator fileMenu.add_command( label="Exit", command=clickExit) # Add the "Exit" menu and bind a function menuBar.add_cascade(label="메뉴", menu=fileMenu) win.resizable(0, 0) # Disable resizing the GUI win.mainloop() # Start GUI
def main_menu(root, end_command): menubar = Menu(root) root.config(menu=menubar) help_menu = Menu(menubar, tearoff=0) help_menu.add_command(label="Settings", command=partial(display_settings_ui, root)) help_menu.add_command(label="About", command=help_about) menubar.add_cascade(label="Tools", menu=help_menu) help_menu.add_separator() help_menu.add_command(label="Exit", command=end_command)
btn_bunch2_rem.grid(row=0, column=1, sticky="WESN", pady=5) frm_bunch2_pnt.grid(row=0, column=0, sticky="WESN") frm_bunch2.grid(row=0, column=1, sticky="WESN") frm_bunch2_key.grid(row=1, column=1, sticky="WESN") # Draw frm_draw = LabelFrame(main_root, text="Изображение") cnv_wall = Canvas(frm_draw, width=cnv_size[0], height=cnv_size[1], bg="white") cnv_wall.pack() frm_draw.grid(row=0, column=2, rowspan=2, sticky="WESN") def main(): global bunch1 global bunch2 for i in range(3): add_point_bunch1() add_point_bunch2() main() start_menu = Menu(main_root, tearoff=0) main_root.config(menu=start_menu) start_menu.add_command(label="Запустить", command=start_search) main_root.mainloop()
from tkinter import Menu from tkinter import messagebox as mBox win = tk.Tk() win.title('Create Menu Bar') # exit GUI cleanly def _quit(): win.quit() win.destroy() exit() #create a menu bar menuBar = Menu(win) win.config(menu=menuBar) # add menu items fileMenu = Menu(menuBar, tearoff=0) fileMenu.add_command(label='New') fileMenu.add_command(label='Open') fileMenu.add_command(label='Save') fileMenu.add_separator() fileMenu.add_command(label='Exit', underline=1, command=_quit) menuBar.add_cascade(label='File', menu=fileMenu) def _msgBox(): #mBox.showinfo('Python Info Box','Creating message dialogs is way easier in Python!')
def __init__(self): root = Tk() root.configure(background='light green') root.title('project') x = Label(root, text="CAB BOOKING SYSTEM", fg="blue", bg="black", font="Verdana 50 bold") x.pack() menu = Menu(root) new_item = Menu(menu) new_item.add_command(label='NEW') new_item.add_command(label='UPDATE', command=self.update) menu.add_cascade(label='HOME', menu=new_item) root.config(menu=menu) new = Menu(menu) new.add_command(label='ABOUT US', command=self.about) menu.add_cascade(label='ABOUT', menu=new) root.config(menu=menu) new1 = Menu(menu) new1.add_command(label='24*7 SUPPORT', command=self.support) new1.add_command(label='Web Support', command=self.web) menu.add_cascade(label='HELP', menu=new1) root.config(menu=menu) a = Label(root, text="_____________") a.pack() y = Label(root, text="FOR LOGIN", fg="blue", font="Verdana 20 bold") y.pack() lb1 = Label(root, text="USER ID") lb1.pack() entry = Entry(root, width=20) entry.pack() entry.get() lb2 = Label(root, text="PASSWORD") lb2.pack() entry1 = Entry(root, width=10) entry1.insert(0, 'enter ur password') entry1.config(show='*') entry1.pack() entry1.get() button = Button(root, text="login", command=self.processbutton) button.pack() c = Label(root, text="_____________") c.pack() lb3 = Label(root, text="FOR CREATING NEW ACCOUNT", fg="blue", font="Verdana 20 bold") lb3.pack() #for sinup frame = Frame(root) frame.pack() bottomframe = Frame(root) bottomframe.pack(side=BOTTOM) redbutton = Button(frame, text='SINUP', fg='blue', command=self.processButton) redbutton.pack(side=LEFT) root.mainloop()
def frame(): global win win = tk.Tk() #win=tk.Tk.Toplevel() win.title("Scraper") win.minsize(width=1200, height=400) # Menu Bar menu_bar = Menu() win.config(menu=menu_bar) file_menu = Menu(menu_bar, tearoff=0) file_menu.add_command(label="Exit", command=quitt) menu_bar.add_cascade(label="File", menu=file_menu) help_menu = Menu(menu_bar, tearoff=0) help_menu.add_command(label="Get Help Here", command=help_page) menu_bar.add_cascade(label="Help", menu=help_menu) about_menu = Menu(menu_bar, tearoff=0) about_menu.add_command(label="Read Here", command=about_page) menu_bar.add_cascade(label="About Me", menu=about_menu) global frame0 frame0 = ttk.Labelframe(text="Enter following details:") frame0.grid(padx=150, pady=100) ttk.Label(frame0, text="Enter Movie Name").grid(column=0, row=0, sticky="W") global x0 x0 = ttk.Entry(frame0) x0.grid(column=1, row=0) btn = ttk.Button(frame0, text="Submit", command=get_name).grid(column=3, row=3) for lopper in frame0.winfo_children(): lopper.grid_configure(padx=5, pady=3)
def create_widgets(self): tabControl = ttk.Notebook(self.win) # Create Tab Control tab1 = ttk.Frame(tabControl) # Create a tab tabControl.add(tab1, text='Tab 1') # Add the tab tab2 = ttk.Frame(tabControl) # Add a second tab tabControl.add(tab2, text='Tab 2') # Make second tab visible tabControl.pack(expand=1, fill="both") # Pack to make visible # LabelFrame using tab1 as the parent mighty = ttk.LabelFrame(tab1, text=' Mighty Python ') mighty.grid(column=0, row=0, padx=8, pady=4) # Modify adding a Label using mighty as the parent instead of win a_label = ttk.Label(mighty, text="Enter a name:") a_label.grid(column=0, row=0, sticky='W') # Adding a Textbox Entry widget self.name = tk.StringVar() self.name_entered = ttk.Entry(mighty, width=24, textvariable=self.name) self.name_entered.grid(column=0, row=1, sticky='W') self.name_entered.delete(0, tk.END) self.name_entered.insert(0, '< default name >') # Adding a Button self.action = ttk.Button(mighty, text="Click Me!", command=self.click_me) self.action.grid(column=2, row=1) ttk.Label(mighty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() self.number_chosen = ttk.Combobox(mighty, width=14, textvariable=number, state='readonly') self.number_chosen['values'] = (1, 2, 4, 42, 100) self.number_chosen.grid(column=1, row=1) self.number_chosen.current(0) # Adding a Spinbox widget self.spin = Spinbox(mighty, values=(1, 2, 4, 42, 100), width=5, bd=9, command=self._spin) # using range self.spin.grid(column=0, row=2, sticky='W') # align left # Using a scrolled Text control scrol_w = 40 scrol_h = 10 # increase sizes self.scrol = scrolledtext.ScrolledText(mighty, width=scrol_w, height=scrol_h, wrap=tk.WORD) self.scrol.grid(column=0, row=3, sticky='WE', columnspan=3) for child in mighty.winfo_children( ): # add spacing to align widgets within tabs child.grid_configure(padx=4, pady=2) #===================================================================================== # Tab Control 2 ---------------------------------------------------------------------- self.mighty2 = ttk.LabelFrame(tab2, text=' The Snake ') self.mighty2.grid(column=0, row=0, padx=8, pady=4) # Creating three checkbuttons chVarDis = tk.IntVar() check1 = tk.Checkbutton(self.mighty2, text="Disabled", variable=chVarDis, state='disabled') check1.select() check1.grid(column=0, row=0, sticky=tk.W) chVarUn = tk.IntVar() check2 = tk.Checkbutton(self.mighty2, text="UnChecked", variable=chVarUn) check2.deselect() check2.grid(column=1, row=0, sticky=tk.W) chVarEn = tk.IntVar() check3 = tk.Checkbutton(self.mighty2, text="Enabled", variable=chVarEn) check3.deselect() check3.grid(column=2, row=0, sticky=tk.W) # trace the state of the two checkbuttons chVarUn.trace('w', lambda unused0, unused1, unused2: self.checkCallback()) chVarEn.trace('w', lambda unused0, unused1, unused2: self.checkCallback()) # First, we change our Radiobutton global variables into a list colors = ["Blue", "Gold", "Red"] # create three Radiobuttons using one variable self.radVar = tk.IntVar() # Next we are selecting a non-existing index value for radVar self.radVar.set(99) # Now we are creating all three Radiobutton widgets within one loop for col in range(3): curRad = tk.Radiobutton(self.mighty2, text=colors[col], variable=self.radVar, value=col, command=self.radCall) curRad.grid(column=col, row=1, sticky=tk.W) # And now adding tooltips ToolTip(curRad, 'This is a Radiobutton control') # Add a Progressbar to Tab 2 self.progress_bar = ttk.Progressbar(tab2, orient='horizontal', length=342, mode='determinate') self.progress_bar.grid(column=0, row=3, pady=2) # Create a container to hold buttons buttons_frame = ttk.LabelFrame(self.mighty2, text=' ProgressBar ') buttons_frame.grid(column=0, row=2, sticky='W', columnspan=2) # Add Buttons for Progressbar commands ttk.Button(buttons_frame, text=" Run Progressbar ", command=self.run_progressbar).grid(column=0, row=0, sticky='W') ttk.Button(buttons_frame, text=" Start Progressbar ", command=self.start_progressbar).grid(column=0, row=1, sticky='W') ttk.Button(buttons_frame, text=" Stop immediately ", command=self.stop_progressbar).grid(column=1, row=0, sticky='W') ttk.Button(buttons_frame, text=" Stop after second ", command=self.progressbar_stop_after).grid(column=1, row=1, sticky='W') for child in buttons_frame.winfo_children(): child.grid_configure(padx=2, pady=2) for child in self.mighty2.winfo_children(): child.grid_configure(padx=8, pady=2) # Create Manage Files Frame ------------------------------------------------ mngFilesFrame = ttk.LabelFrame(tab2, text=' Manage Files: ') mngFilesFrame.grid(column=0, row=1, sticky='WE', padx=10, pady=5) # Button Callback def getFileName(): print('hello from getFileName') fDir = path.dirname(__file__) fName = fd.askopenfilename(parent=self.win, initialdir=fDir) print(fName) self.fileEntry.config(state='enabled') self.fileEntry.delete(0, tk.END) self.fileEntry.insert(0, fName) if len(fName) > self.entryLen: self.fileEntry.config(width=len(fName) + 3) # Add Widgets to Manage Files Frame lb = ttk.Button(mngFilesFrame, text="Browse to File...", command=getFileName) lb.grid(column=0, row=0, sticky=tk.W) #----------------------------------------------------- file = tk.StringVar() self.entryLen = scrol_w - 4 self.fileEntry = ttk.Entry(mngFilesFrame, width=self.entryLen, textvariable=file) self.fileEntry.grid(column=1, row=0, sticky=tk.W) #----------------------------------------------------- logDir = tk.StringVar() self.netwEntry = ttk.Entry(mngFilesFrame, width=self.entryLen, textvariable=logDir) self.netwEntry.grid(column=1, row=1, sticky=tk.W) def copyFile(): import shutil src = self.fileEntry.get() file = src.split('/')[-1] dst = self.netwEntry.get() + '\\' + file try: shutil.copy(src, dst) msg.showinfo('Copy File to Network', 'Succes: File copied.') except FileNotFoundError as err: msg.showerror('Copy File to Network', '*** Failed to copy file! ***\n\n' + str(err)) except Exception as ex: msg.showerror('Copy File to Network', '*** Failed to copy file! ***\n\n' + str(ex)) cb = ttk.Button(mngFilesFrame, text="Copy File To : ", command=copyFile) cb.grid(column=0, row=1, sticky=tk.E) # Add some space around each label for child in mngFilesFrame.winfo_children(): child.grid_configure(padx=6, pady=6) # Creating a Menu Bar ========================================================== menu_bar = Menu(self.win) self.win.config(menu=menu_bar) # Add menu items file_menu = Menu(menu_bar, tearoff=0) file_menu.add_command(label="New") file_menu.add_separator() file_menu.add_command(label="Exit", command=self._quit) menu_bar.add_cascade(label="File", menu=file_menu) # Display a Message Box def _msgBox(): msg.showinfo( 'Python Message Info Box', 'A Python GUI created using tkinter:\nThe year is 2019.') # Add another Menu to the Menu Bar and an item help_menu = Menu(menu_bar, tearoff=0) help_menu.add_command( label="About", command=_msgBox) # display messagebox when clicked menu_bar.add_cascade(label="Help", menu=help_menu) # Change the main windows icon self.win.iconbitmap('pyc.ico') # It is not necessary to create a tk.StringVar() # strData = tk.StringVar() strData = self.spin.get() # call function self.usingGlobal() # self.name_entered.focus() # Set focus to Tab 2 tabControl.select(1) # Add Tooltips ----------------------------------------------------- # Add a Tooltip to the Spinbox ToolTip(self.spin, 'This is a Spinbox control') # Add Tooltips to more widgets ToolTip(self.name_entered, 'This is an Entry control') ToolTip(self.action, 'This is a Button control') ToolTip(self.scrol, 'This is a ScrolledText control')
# Place labels into the container element ttk.Label(buttons_frame, text="Label1").grid(column=0, row=0, sticky=tk.W) ttk.Label(buttons_frame, text="Label2").grid(column=1, row=0, sticky=tk.W) ttk.Label(buttons_frame, text="Label3").grid(column=2, row=0, sticky=tk.W) # Exit GUI cleanly def _quit(): win.quit() win.destroy() exit() # Creating a Menu Bar menu_bar = Menu(win) win.config(menu=menu_bar) # Add menu items file_menu = Menu(menu_bar, tearoff=0) file_menu.add_command(label="New") file_menu.add_separator() file_menu.add_command(label="Exit", command=_quit) menu_bar.add_cascade(label="File", menu=file_menu) # Display a Message Box def _msgBox(): msg.showinfo('Python Message Info Box', 'A Python GUI created using tkinter:\nThe year is 2017.')
foreground=orderFontData['foreground'], selectbackground=orderFontData['selectbackground']) order = StringVar() orderFont = font.Font(family=orderFontData['font'], size=orderFontData['fontSize']) inputboxWidth = int(GameConfig.textbox_width) - cursorWidth inputbox = ttk.Entry(inputBackgroundBox, style='EntryStyle.TEntry', textvariable=order, font=orderFont, width=inputboxWidth) inputbox.grid(column=1, row=0, sticky=(N, E, S)) # 构建菜单栏 root.option_add('*tearOff', FALSE) menubar = Menu(root) root['menu'] = menubar menufile = Menu(menubar) menutest = Menu(menubar) menuother = Menu(menubar) menubar.add_cascade(menu=menufile, label=TextLoading.getTextData(TextLoading.menuPath, TextLoading.menuFile)) menubar.add_cascade(menu=menuother, label=TextLoading.getTextData(TextLoading.menuPath, TextLoading.menuOther)) def reset(*args): CacheContorl.flowContorl['restartGame'] = 1 send_input()
for i in range(2): canvas = 'canvas' + str(col) canvas = tk.Canvas(tab3, width=162, height=95, highlightthickness=0, bg='#FFFF00') canvas.grid(row=i, column=i) #---------------Tab3控件介绍------------------# #----------------菜单栏介绍-------------------# # Exit GUI cleanly def _quit(): win.quit() win.destroy() exit() # Creating a Menu Bar menuBar = Menu(win) win.config(menu=menuBar) # Add menu items fileMenu = Menu(menuBar, tearoff=0) fileMenu.add_command(label="新建") fileMenu.add_separator() fileMenu.add_command(label="退出", command=_quit) menuBar.add_cascade(label="文件", menu=fileMenu) # Display a Message Box def _msgBox1(): mBox.showinfo('Python Message Info Box', '通知:程序运行正常!') def _msgBox2(): mBox.showwarning('Python Message Warning Box', '警告:程序出现错误,请检查!')
lb.place(x=25, y=25) mb = tk.Menubutton(root, text="File", relief=tk.FLAT, cursor='hand2') mb.place(x=50, y=0) mb2 = tk.Menubutton(root, text='Help', relief=FLAT, cursor='hand2') mb2.place(x=85, y=0) filemenu = tk.Menu(mb, tearoff=False) filemenu.add_command(label="Exit", command=root.quit, font=("Arial", 9), accelerator='Ctrl+E') mb.config(menu=filemenu) root.bind_all("<Control-e>", lambda event: root.quit()) root.bind_all("<Control-a>", lambda event: _about()) helpmenu = Menu(mb2, tearoff=False) helpmenu.add_command(label='About', command=_about, font=("Arial", 9), accelerator='Ctrl+A') mb2.config(menu=helpmenu) # Update 2020.5.26: hmm..I really wonder how I did this in 2019, but writing 2019-2020... copy = Label(tab1, text="Copy Right © 2019-2020 Sam Tech.co.,Inc.", font=("Arial", 10)) copy.place(x=1000, y=700) tab1.update() def GetSize(event): global statusbar
from tkinter import ttk from tkinter import Menu win = tk.Tk() win.title('Create Menu Bar') # exit GUI cleanly def _quit(): win.quit() win.destroy() exit() #create a menu bar menuBar = Menu(win) win.config(menu=menuBar) # add menu items fileMenu = Menu(menuBar, tearoff=0) fileMenu.add_command(label='New') fileMenu.add_command(label='Open') fileMenu.add_command(label='Save') fileMenu.add_separator() fileMenu.add_command(label='Exit', underline=1, command=_quit) menuBar.add_cascade(label='File', menu=fileMenu) # adding a second menu helpMenu = Menu(menuBar, tearoff=0) helpMenu.add_command(label='About')
def __init__(self, parent_frame, grid_col, grid_row, data): self._data = data self._parent = parent_frame self._frame = ttk.Frame(self._parent, borderwidth=2, relief='sunken') self._frame.grid(column=grid_col, row=grid_row) self._menu = Menu(master=self._parent, tearoff=0) self._menu.add_command(label='info', command=self.info_popup) self._should_plot = tk.BooleanVar() self._should_plot.set(False) def menu_popup(event): self._menu.post(event.x_root, event.y_root) self._chkbox = ttk.Checkbutton(self._frame, text="Plot", variable=self._should_plot, onvalue=True) self._chkbox.pack() self._button = ttk.Button(self._frame, text="{} -> {}".format(grid_row, grid_col), command=self.info_popup ) self._button.pack() self._button.bind('<Button-3>', menu_popup)