Python ttk.Entry() Examples
The following are 30
code examples of ttk.Entry().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ttk
, or try the search function
.

Example #1
Source File: annotation_gui.py From SEM with MIT License | 9 votes |
def preferences(self, event=None): preferenceTop = tkinter.Toplevel() preferenceTop.focus_set() notebook = ttk.Notebook(preferenceTop) frame1 = ttk.Frame(notebook) notebook.add(frame1, text='general') frame2 = ttk.Frame(notebook) notebook.add(frame2, text='shortcuts') c = ttk.Checkbutton(frame1, text="Match whole word when broadcasting annotation", variable=self._whole_word) c.pack() shortcuts_vars = [] shortcuts_gui = [] cur_row = 0 j = -1 frame_list = [] frame_list.append(ttk.LabelFrame(frame2, text="common shortcuts")) frame_list[-1].pack(fill="both", expand="yes") for i, shortcut in enumerate(self.shortcuts): j += 1 key, cmd, bindings = shortcut name, command = cmd shortcuts_vars.append(tkinter.StringVar(frame_list[-1], value=key)) tkinter.Label(frame_list[-1], text=name).grid(row=cur_row, column=0, sticky=tkinter.W) entry = tkinter.Entry(frame_list[-1], textvariable=shortcuts_vars[j]) entry.grid(row=cur_row, column=1) cur_row += 1 notebook.pack() # # ? menu methods #
Example #2
Source File: Skeleton_Key.py From firmware_password_manager with MIT License | 6 votes |
def main(): """ Entry into script. """ master_version = "1.0" logging.basicConfig(filename='/tmp/skeleton_key_v' + master_version + '.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') logger = logging.getLogger(__name__) logger.info("Running Skeleton Key " + master_version) root = Tk() try: admin_password, fwpw_status = login(root, logger) except Exception as exception_message: logger.error("%s: Error logging in. [%s]" % (inspect.stack()[0][3], exception_message)) sys.exit(0) root.deiconify() SinglePane(root, logger, admin_password, fwpw_status, master_version) root.mainloop()
Example #3
Source File: tkinter_gui.py From ChatterBot with BSD 3-Clause "New" or "Revised" License | 6 votes |
def initialize(self): """ Set window layout. """ self.grid() self.respond = ttk.Button(self, text='Get Response', command=self.get_response) self.respond.grid(column=0, row=0, sticky='nesw', padx=3, pady=3) self.usr_input = ttk.Entry(self, state='normal') self.usr_input.grid(column=1, row=0, sticky='nesw', padx=3, pady=3) self.conversation_lbl = ttk.Label(self, anchor=tk.E, text='Conversation:') self.conversation_lbl.grid(column=0, row=1, sticky='nesw', padx=3, pady=3) self.conversation = ScrolledText.ScrolledText(self, state='disabled') self.conversation.grid(column=0, row=2, columnspan=2, sticky='nesw', padx=3, pady=3)
Example #4
Source File: dateentry.py From tkcalendar with GNU General Public License v3.0 | 6 votes |
def state(self, *args): """ Modify or inquire widget state. Widget state is returned if statespec is None, otherwise it is set according to the statespec flags and then a new state spec is returned indicating which flags were changed. statespec is expected to be a sequence. """ if args: # change cursor depending on state to mimic Combobox behavior states = args[0] if 'disabled' in states or 'readonly' in states: self.configure(cursor='arrow') elif '!disabled' in states or '!readonly' in states: self.configure(cursor='xterm') return ttk.Entry.state(self, *args)
Example #5
Source File: myNotebook.py From EDMarketConnector with GNU General Public License v2.0 | 5 votes |
def __init__(self, master=None, **kw): if platform == 'darwin': kw['highlightbackground'] = kw.pop('highlightbackground', PAGEBG) tk.Entry.__init__(self, master, **kw) else: ttk.Entry.__init__(self, master, **kw)
Example #6
Source File: userInterface.py From PcapXray with GNU General Public License v2.0 | 5 votes |
def __init__(self, base): # Base Frame Configuration self.base = base base.title("PcapXray") Label(base, text="PcapXray Tool - A LAN Network Analyzer") # Style Configuration style = ttk.Style() style.configure("BW.TLabel", foreground="black") style.configure("BW.TEntry", foreground="black") # 1st Frame - Initial Frame InitFrame = ttk.Frame(base, width=50, padding="10 10 10 10",relief= GROOVE) InitFrame.grid(column=10, row=10, sticky=(N, W, E, S)) InitFrame.columnconfigure(10, weight=1) InitFrame.rowconfigure(10, weight=1) # Pcap File Entry self.pcap_file = StringVar() self.filename = "" ttk.Label(InitFrame, text="Enter pcap file path: ",style="BW.TLabel").grid(column=0, row=0, sticky="W") self.filename_field = ttk.Entry(InitFrame, width=30, textvariable=self.pcap_file, style="BW.TEntry").grid(column=1, row=0, sticky="W, E") self.progressbar = ttk.Progressbar(InitFrame, orient="horizontal", length=200,value=0, maximum=200, mode="indeterminate") # Browse button #self.filename = StringVar() ttk.Button(InitFrame, text="Browse", command=self.browse_directory).grid(column=2, row=0, padx=10, pady=10,sticky="E") ttk.Button(InitFrame, text="Analyze!", command=self.pcap_analyse).grid(column=3, row=0, padx=10, pady=10,sticky="E") self.progressbar.grid(column=4, row=0, padx=10, pady=10, sticky="E") # Second Frame with Options SecondFrame = ttk.Frame(base, width=50, padding="10 10 10 10",relief= GROOVE) SecondFrame.grid(column=10, row=20, sticky=(N, W, E, S)) SecondFrame.columnconfigure(10, weight=1) SecondFrame.rowconfigure(10, weight=1) ttk.Label(SecondFrame, text="Options: ", style="BW.TLabel").grid(row=10,column=0,sticky="W") self.option = StringVar() self.options = {'All','HTTP','HTTPS','Tor','Malicious'} #self.option.set('Tor') ttk.OptionMenu(SecondFrame,self.option,"Select",*self.options).grid(row=10,column=1,sticky="W") self.zoom = [900,900] self.img = "" ttk.Button(SecondFrame, text="zoomIn", command=self.zoom_in).grid(row=10,column=10,padx=5,sticky="E") ttk.Button(SecondFrame, text="zoomOut", command=self.zoom_out).grid(row=10,column=11,sticky="E") # Third Frame with Results and Descriptioms self.ThirdFrame = ttk.Frame(base, width=100, height=100, padding="10 10 10 10",relief= GROOVE) description = """It is a tool aimed to simplyfy the network analysis and speed the process of analysing the network traffic.\nThis prototype aims to accomplish 4 important modules, \n 1. Web Traffic\n 2. Tor Traffic \n 3. Malicious Traffic \n 4. Device/Traffic Details\n\nPlease contact me @ spg349@nyu.edu for any bugs or problems ! """ self.label = ttk.Label(self.ThirdFrame, text="Description: \nPcapXray tools is an aid for Network Forensics or Any Network Analysis!\n"+description, style="BW.TLabel") self.label.grid(column=10, row=10,sticky="W") self.xscrollbar = Scrollbar(self.ThirdFrame, orient=HORIZONTAL) self.xscrollbar.grid(row=100, column=0, sticky=E + W) self.yscrollbar = Scrollbar(self.ThirdFrame, orient=VERTICAL) self.yscrollbar.grid(row=0, column=100, sticky=N + S) self.ThirdFrame.grid(column=10, row=30, sticky=(N, W, E, S)) self.ThirdFrame.columnconfigure(0, weight=1) self.ThirdFrame.rowconfigure(0, weight=1) self.name_servers = ""
Example #7
Source File: test_widgets.py From BinderFilter with MIT License | 5 votes |
def setUp(self): support.root_deiconify() self.entry = ttk.Entry()
Example #8
Source File: test_widgets.py From oss-ftp with MIT License | 5 votes |
def create(self, **kwargs): return ttk.Entry(self.root, **kwargs)
Example #9
Source File: main.py From aurora-sdk-mac with Apache License 2.0 | 5 votes |
def show_window(self): self.mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) self.mainframe.columnconfigure(0, weight=1) self.mainframe.rowconfigure(0, weight=1) ttk.Label(self.mainframe, text=" ").grid(column=0, row=0, sticky=(N,W)) ttk.Label(self.mainframe, text='1. Pair your Light Panels ').grid(column=1, row=1, sticky=(N, W)) ttk.Checkbutton(self.mainframe, variable=self.should_use_simulator, text='Use Light Panels Simulator', command=self.toggle_aurora_simulator).grid(column=2, row=1, sticky=(N,W)) ttk.Label(self.mainframe, text='IP Address').grid(column=1, row=2, sticky=(N, W)) self.pair_entry = ttk.Entry(self.mainframe, width=35, textvariable=self.ip_addr) self.pair_entry.grid(column=2, row=2, columnspan=2, sticky=(N, W)) self.pair_button = ttk.Button(self.mainframe, width=12, text='Pair', command=self.authenticate_with_aurora) self.pair_button.grid(column=4, row=2, sticky=(N,W)) ttk.Label(self.mainframe, text='2. Make a color palette').grid(column=1, row=3, sticky=(N, W)) ttk.Button(self.mainframe, text="Add Color", command=self.add_color_to_palette).grid(column=1, row=4, sticky=(N, W)) ttk.Label(self.mainframe, textvariable=self.curr_palette_string, wraplength=500).grid(column=2, row=4, columnspan=2, sticky=(N, W)) ttk.Button(self.mainframe, width=12, text="Clear palette", command=self.clear_palette).grid(column=4, row=4, sticky=(N, W)) ttk.Label(self.mainframe, text='3. Build your plugin').grid(column=1, row=5, sticky=(N, W)) ttk.Label(self.mainframe, text='Plugin Location').grid(column=1, row=6, sticky=(N, W)) ttk.Entry(self.mainframe, width=35, textvariable=self.plugin_dir_path).grid(column=2, row=6, columnspan=2, sticky=(N, W)) ttk.Button(self.mainframe, width=12, text='Browse', command=self.get_plugin_dir).grid(column=4, row=6, sticky=(N, W)) ttk.Button(self.mainframe, text='Build', command=self.build_plugin).grid(column=2, row=7, columnspan=1, sticky=(N,E)) ttk.Button(self.mainframe, text='Upload & Run', command=self.play_plugin).grid(column=3, row=7, columnspan=1, sticky=N) ttk.Button(self.mainframe, width=12, text='Stop Plugin', command=self.stop_plugin).grid(column=4, row=7, columnspan=1, sticky=(N, W)) ttk.Label(self.mainframe, text=" ").grid(column=5, row=8, sticky=(N,W)) ttk.Label(self.mainframe, text=" ").grid(column=5, row=9, sticky=(N,W)) self.pluginOptionsGUI.create_plugin_frame() self.root.mainloop()
Example #10
Source File: ttk_spinbox.py From stochopy with MIT License | 5 votes |
def __init__(self, master = None, **kwargs): ttk.Entry.__init__(self, master, "ttk::spinbox", **kwargs)
Example #11
Source File: gui.py From stochopy with MIT License | 5 votes |
def _entry(self, variable, position, kwargs = {}): entry = ttk.Entry(self.frame1.sliders, textvariable = variable, justify = "right", takefocus = True, **kwargs) if position == 1: entry.place(width = 45, relx = 0.35, x = -3, y = 26, anchor = "nw") elif position == 2: entry.place(width = 45, relx = 0.35, x = -3, y = 71, anchor = "nw") elif position == 3: entry.place(width = 45, relx = 0.85, x = -3, y = 26, anchor = "nw") elif position == 4: entry.place(width = 45, relx = 0.85, x = -3, y = 71, anchor = "nw") return entry
Example #12
Source File: dialog_elements.py From Enrich2 with BSD 3-Clause "New" or "Revised" License | 5 votes |
def body(self, master, row, columns=DEFAULT_COLUMNS, **kwargs): """ Place the required elements using the grid layout method. Returns the number of rows taken by this element. """ label = ttk.Label(master, text=self.text) label.grid(row=row, column=0, columnspan=1, sticky="e") self.entry = ttk.Entry(master, textvariable=self.value) self.entry.grid(row=row, column=1, columnspan=columns - 1, sticky="ew") return 1
Example #13
Source File: dialog_elements.py From Enrich2 with BSD 3-Clause "New" or "Revised" License | 5 votes |
def body(self, master, row, columns=DEFAULT_COLUMNS, **kwargs): """ Place the required elements using the grid layout method. Returns the number of rows taken by this element. """ label = ttk.Label(master, text=self.text) label.grid(row=row, column=0, columnspan=1, sticky="e") self.entry = ttk.Entry(master, textvariable=self.value) self.entry.grid(row=row, column=1, columnspan=columns - 1, sticky="ew") if self.directory: self.choose = ttk.Button( master, text="Choose...", command=lambda: self.value.set(tkFileDialog.askdirectory()), ) else: self.choose = ttk.Button( master, text="Choose...", command=lambda: self.value.set(tkFileDialog.askopenfilename()), ) self.choose.grid(row=row + 1, column=1, sticky="w") if self.optional: self.clear = ttk.Button( master, text="Clear", command=lambda: self.value.set("") ) self.clear.grid(row=row + 1, column=2, sticky="e") return 2
Example #14
Source File: dialog_elements.py From Enrich2 with BSD 3-Clause "New" or "Revised" License | 5 votes |
def body(self, master, row, columns=DEFAULT_COLUMNS, **kwargs): """ Place the required elements using the grid layout method. Returns the number of rows taken by this element. """ label = ttk.Label(master, text=self.text) label.grid(row=row, column=0, columnspan=1, sticky="e") self.entry = ttk.Entry(master, textvariable=self.value) self.entry.grid(row=row, column=1, columnspan=columns - 1, sticky="ew") return 1
Example #15
Source File: dialog_elements.py From Enrich2 with BSD 3-Clause "New" or "Revised" License | 5 votes |
def body(self, master, row, columns=DEFAULT_COLUMNS, width=4, left=False, **kwargs): """ Add the labeled entry to the Frame *master* using grid at *row*. *width* controls the width of the Entry. *left* is ``True`` if the Entry is to the left of the Label. *columns* is the number of columns in *master*. Returns the number of rows taken by this element. """ if left: entry_column = 0 entry_sticky = "e" entry_width = 1 label_column = 1 label_sticky = "w" label_width = columns - 1 else: entry_column = 1 entry_sticky = "w" entry_width = columns - 1 label_column = 0 label_sticky = "e" label_width = 1 label = ttk.Label(master, text=self.text) label.grid( row=row, column=label_column, columnspan=label_width, sticky=label_sticky ) self.entry = ttk.Entry(master, textvariable=self.value, width=width) self.entry.grid( row=row, column=entry_column, columnspan=entry_width, sticky=entry_sticky ) return 1
Example #16
Source File: dateentry.py From tkcalendar with GNU General Public License v3.0 | 5 votes |
def _on_motion(self, event): """Set widget state depending on mouse position to mimic Combobox behavior.""" x, y = event.x, event.y if 'disabled' not in self.state(): if self.identify(x, y) == self._downarrow_name: self.state(['active']) ttk.Entry.configure(self, cursor='arrow') else: self.state(['!active']) ttk.Entry.configure(self, cursor=self._cursor)
Example #17
Source File: dateentry.py From tkcalendar with GNU General Public License v3.0 | 5 votes |
def destroy(self): try: self.after_cancel(self._determine_downarrow_name_after_id) except ValueError: # nothing to cancel pass ttk.Entry.destroy(self)
Example #18
Source File: dateentry.py From tkcalendar with GNU General Public License v3.0 | 5 votes |
def cget(self, key): """Return the resource value for a KEY given as string.""" if key in self.entry_kw: return ttk.Entry.cget(self, key) elif key == 'calendar_cursor': return self._calendar.cget('cursor') else: return self._calendar.cget(key)
Example #19
Source File: dateentry.py From tkcalendar with GNU General Public License v3.0 | 5 votes |
def configure(self, cnf={}, **kw): """ Configure resources of a widget. The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method :meth:`~DateEntry.keys`. """ if not isinstance(cnf, dict): raise TypeError("Expected a dictionary or keyword arguments.") kwargs = cnf.copy() kwargs.update(kw) entry_kw = {} keys = list(kwargs.keys()) for key in keys: if key in self.entry_kw: entry_kw[key] = kwargs.pop(key) font = kwargs.get('font', None) if font is not None: entry_kw['font'] = font self._cursor = str(entry_kw.get('cursor', self._cursor)) if entry_kw.get('state') == 'readonly' and self._cursor == 'xterm' and 'cursor' not in entry_kw: entry_kw['cursor'] = 'arrow' self._cursor = 'arrow' ttk.Entry.configure(self, entry_kw) kwargs['cursor'] = kwargs.pop('calendar_cursor', None) self._calendar.configure(kwargs) if 'date_pattern' in kwargs or 'locale' in kwargs: self._set_text(self.format_date(self._date))
Example #20
Source File: date_decoder.py From Learning-Python-for-Forensics-Second-Edition with MIT License | 5 votes |
def build_input_frame(self): """ The build_input_frame method builds the interface for the input frame """ # Frame Init self.input_frame = ttk.Frame(self.root) self.input_frame.config(padding = (30,0)) self.input_frame.pack() # Input Value ttk.Label(self.input_frame, text="Enter Time Value").grid(row=0, column=0) self.input_time = StringVar() ttk.Entry(self.input_frame, textvariable=self.input_time, width=25).grid(row=0, column=1, padx=5) # Radiobuttons self.time_type = StringVar() self.time_type.set('raw') ttk.Radiobutton(self.input_frame, text="Raw Value", variable=self.time_type, value="raw").grid(row=1, column=0, padx=5) ttk.Radiobutton(self.input_frame, text="Formatted Value", variable=self.time_type, value="formatted").grid( row=1, column=1, padx=5) # Button ttk.Button(self.input_frame, text="Run", command=self.convert).grid( row=2, columnspan=2, pady=5)
Example #21
Source File: test_widgets.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def create(self, **kwargs): return ttk.Entry(self.root, **kwargs)
Example #22
Source File: Skeleton_Key.py From firmware_password_manager with MIT License | 4 votes |
def master_pane(self): """ The home pane. """ self.logger.info("%s: activated" % inspect.stack()[0][3]) self.logger.info("%s" % inspect.stack()[1][3]) self.mainframe = ttk.Frame(self.superframe, width=604, height=510) self.mainframe.grid(column=0, row=2, sticky=(N, W, E, S)) self.mainframe.grid_rowconfigure(0, weight=1) self.mainframe.grid_rowconfigure(5, weight=1) self.mainframe.grid_columnconfigure(0, weight=1) self.mainframe.grid_columnconfigure(2, weight=1) self.change_state_btn = ttk.Button(self.mainframe, width=20, text="Change State", command=self.change_state) self.change_state_btn.grid(column=0, row=80, pady=4, columnspan=3) self.change_state_btn.configure(state=self.state_button_state) self.info_status_label = ttk.Label(self.mainframe, text='Location of keyfile:') self.info_status_label.grid(column=0, row=90, pady=8, columnspan=3) ttk.Button(self.mainframe, width=20, text="Retrieve from JSS Script", command=self.jss_pane).grid(column=0, row=100, pady=4, columnspan=3) ttk.Button(self.mainframe, width=20, text="Fetch from Remote Volume", command=self.remote_nav_pane).grid(column=0, row=200, pady=4, columnspan=3) ttk.Button(self.mainframe, width=20, text="Retrieve from Local Volume", command=self.local_nav_pane).grid(column=0, row=300, pady=4, columnspan=3) ttk.Button(self.mainframe, width=20, text="Enter Firmware Password", command=self.direct_entry_pane).grid(column=0, row=320, pady=4, columnspan=3) ttk.Separator(self.mainframe, orient=HORIZONTAL).grid(row=400, columnspan=3, sticky=(E, W), pady=8) hash_display = ttk.Entry(self.mainframe, width=58, textvariable=self.hashed_results) hash_display.grid(column=0, row=450, columnspan=4) self.hash_btn = ttk.Button(self.mainframe, width=20, text="Copy hash to clipboard", command=self.copy_hash) self.hash_btn.grid(column=0, row=500, pady=4, columnspan=3) self.hash_btn.configure(state=self.hash_button_state) ttk.Separator(self.mainframe, orient=HORIZONTAL).grid(row=700, columnspan=3, sticky=(E, W), pady=8) self.status_label = ttk.Label(self.mainframe, textvariable=self.status_string) self.status_label.grid(column=0, row=2100, sticky=W, columnspan=2) ttk.Button(self.mainframe, text="Quit", width=6, command=self.root.destroy).grid(column=2, row=2100, sticky=E)
Example #23
Source File: Skeleton_Key.py From firmware_password_manager with MIT License | 4 votes |
def remote_nav_pane(self): """ Connect to server and select keyfile. """ self.logger.info("%s: activated" % inspect.stack()[0][3]) self.mainframe.grid_remove() try: if self.config_options["keyfile"]["remote_type"] == 'smb': if self.config_options["keyfile"]["server_path"]: self.remote_hostname.set(self.config_options["keyfile"]["server_path"]) if self.config_options["keyfile"]["username"]: self.remote_username.set(self.config_options["keyfile"]["username"]) if self.config_options["keyfile"]["password"]: self.remote_password.set(self.config_options["keyfile"]["password"]) except: pass self.remote_nav_frame = ttk.Frame(self.superframe, width=604, height=510) self.remote_nav_frame.grid(column=0, row=2, sticky=(N, W, E, S)) self.remote_nav_frame.grid_columnconfigure(0, weight=1) self.remote_nav_frame.grid_columnconfigure(1, weight=1) self.remote_nav_frame.grid_columnconfigure(2, weight=1) self.remote_nav_frame.grid_columnconfigure(3, weight=1) ttk.Label(self.remote_nav_frame, text="Read keyfile from remote server: (ie smb://...)").grid(column=0, row=100, columnspan=4, sticky=(E, W)) ttk.Label(self.remote_nav_frame, text="Server path:").grid(column=0, row=150, sticky=E) hname_entry = ttk.Entry(self.remote_nav_frame, width=30, textvariable=self.remote_hostname) hname_entry.grid(column=1, row=150, sticky=W, columnspan=2) ttk.Label(self.remote_nav_frame, text="Username:").grid(column=0, row=200, sticky=E) uname_entry = ttk.Entry(self.remote_nav_frame, width=30, textvariable=self.remote_username) uname_entry.grid(column=1, row=200, sticky=W, columnspan=2) ttk.Label(self.remote_nav_frame, text="Password:").grid(column=0, row=250, sticky=E) pword_entry = ttk.Entry(self.remote_nav_frame, width=30, textvariable=self.remote_password, show="*") pword_entry.grid(column=1, row=250, sticky=W, columnspan=2) ttk.Button(self.remote_nav_frame, text="Read keyfile", width=15, default='active', command=self.read_remote).grid(column=1, row=300, columnspan=2, pady=12) ttk.Separator(self.remote_nav_frame, orient=HORIZONTAL).grid(row=1000, columnspan=50, pady=12, sticky=(E, W)) ttk.Button(self.remote_nav_frame, text="Return to home", command=self.master_pane).grid(column=2, row=1100, sticky=E) ttk.Button(self.remote_nav_frame, text="Quit", width=6, command=self.root.destroy).grid(column=3, row=1100, sticky=W)
Example #24
Source File: theme.py From EDMarketConnector with GNU General Public License v2.0 | 4 votes |
def register(self, widget): # Note widget and children for later application of a theme. Note if the widget has explicit fg or bg attributes. assert isinstance(widget, tk.Widget) or isinstance(widget, tk.BitmapImage), widget if not self.defaults: # Can't initialise this til window is created # Windows, MacOS self.defaults = { 'fg' : tk.Label()['foreground'], # SystemButtonText, systemButtonText 'bg' : tk.Label()['background'], # SystemButtonFace, White 'font' : tk.Label()['font'], # TkDefaultFont 'bitmapfg' : tk.BitmapImage()['foreground'], # '-foreground {} {} #000000 #000000' 'bitmapbg' : tk.BitmapImage()['background'], # '-background {} {} {} {}' 'entryfg' : tk.Entry()['foreground'], # SystemWindowText, Black 'entrybg' : tk.Entry()['background'], # SystemWindow, systemWindowBody 'entryfont' : tk.Entry()['font'], # TkTextFont 'frame' : tk.Frame()['background'], # SystemButtonFace, systemWindowBody 'menufg' : tk.Menu()['foreground'], # SystemMenuText, 'menubg' : tk.Menu()['background'], # SystemMenu, 'menufont' : tk.Menu()['font'], # TkTextFont } if widget not in self.widgets: # No general way to tell whether the user has overridden, so compare against widget-type specific defaults attribs = set() if isinstance(widget, tk.BitmapImage): if widget['foreground'] not in ['', self.defaults['bitmapfg']]: attribs.add('fg') if widget['background'] not in ['', self.defaults['bitmapbg']]: attribs.add('bg') elif isinstance(widget, tk.Entry) or isinstance(widget, ttk.Entry): if widget['foreground'] not in ['', self.defaults['entryfg']]: attribs.add('fg') if widget['background'] not in ['', self.defaults['entrybg']]: attribs.add('bg') if 'font' in widget.keys() and str(widget['font']) not in ['', self.defaults['entryfont']]: attribs.add('font') elif isinstance(widget, tk.Frame) or isinstance(widget, ttk.Frame) or isinstance(widget, tk.Canvas): if ('background' in widget.keys() or isinstance(widget, tk.Canvas)) and widget['background'] not in ['', self.defaults['frame']]: attribs.add('bg') elif isinstance(widget, HyperlinkLabel): pass # Hack - HyperlinkLabel changes based on state, so skip elif isinstance(widget, tk.Menu): if widget['foreground'] not in ['', self.defaults['menufg']]: attribs.add('fg') if widget['background'] not in ['', self.defaults['menubg']]: attribs.add('bg') if widget['font'] not in ['', self.defaults['menufont']]: attribs.add('font') else: # tk.Button, tk.Label if 'foreground' in widget.keys() and widget['foreground'] not in ['', self.defaults['fg']]: attribs.add('fg') if 'background' in widget.keys() and widget['background'] not in ['', self.defaults['bg']]: attribs.add('bg') if 'font' in widget.keys() and widget['font'] not in ['', self.defaults['font']]: attribs.add('font') self.widgets[widget] = attribs if isinstance(widget, tk.Frame) or isinstance(widget, ttk.Frame): for child in widget.winfo_children(): self.register(child)
Example #25
Source File: theme.py From EDMarketConnector with GNU General Public License v2.0 | 4 votes |
def _update_widget(self, widget): assert widget in self.widgets, '%s %s "%s"' %(widget.winfo_class(), widget, 'text' in widget.keys() and widget['text']) attribs = self.widgets.get(widget, []) if isinstance(widget, tk.BitmapImage): # not a widget if 'fg' not in attribs: widget.configure(foreground = self.current['foreground']), if 'bg' not in attribs: widget.configure(background = self.current['background']) elif 'cursor' in widget.keys() and str(widget['cursor']) not in ['', 'arrow']: # Hack - highlight widgets like HyperlinkLabel with a non-default cursor if 'fg' not in attribs: widget.configure(foreground = self.current['highlight']), if 'insertbackground' in widget.keys(): # tk.Entry widget.configure(insertbackground = self.current['foreground']), if 'bg' not in attribs: widget.configure(background = self.current['background']) if 'highlightbackground' in widget.keys(): # tk.Entry widget.configure(highlightbackground = self.current['background']) if 'font' not in attribs: widget.configure(font = self.current['font']) elif 'activeforeground' in widget.keys(): # e.g. tk.Button, tk.Label, tk.Menu if 'fg' not in attribs: widget.configure(foreground = self.current['foreground'], activeforeground = self.current['activeforeground'], disabledforeground = self.current['disabledforeground']) if 'bg' not in attribs: widget.configure(background = self.current['background'], activebackground = self.current['activebackground']) if platform == 'darwin' and isinstance(widget, tk.Button): widget.configure(highlightbackground = self.current['background']) if 'font' not in attribs: widget.configure(font = self.current['font']) elif 'foreground' in widget.keys(): # e.g. ttk.Label if 'fg' not in attribs: widget.configure(foreground = self.current['foreground']), if 'bg' not in attribs: widget.configure(background = self.current['background']) if 'font' not in attribs: widget.configure(font = self.current['font']) elif 'background' in widget.keys() or isinstance(widget, tk.Canvas): # e.g. Frame, Canvas if 'bg' not in attribs: widget.configure(background = self.current['background'], highlightbackground = self.current['disabledforeground']) # Apply configured theme
Example #26
Source File: annotation_gui.py From SEM with MIT License | 4 votes |
def auth(self, event=None): authTop = tkinter.Toplevel() authTop.grab_set() auth_login = tkinter.StringVar(authTop, value="admin") auth_pw = tkinter.StringVar(authTop, value="") def close(): sys.exit(0) authTop.protocol('WM_DELETE_WINDOW', close) def check_auth(): import time, hashlib pwd = auth_pw.get() if pwd == "": print("Please enter non empty password") try: content = open(".users").read() if "d033e22ae348aeb5660fc2140aec35850c4da997aee5aca44055f2cd2f2ce4266909b69a5d96dad2\n" not in content: print("Something fishy about your .user file, rewriting it with admin user only.") with codecs.open(".users", "w") as O: O.write("d033e22ae348aeb5660fc2140aec35850c4da997aee5aca44055f2cd2f2ce4266909b69a5d96dad2\n") time.sleep(5.0) sys.exit(1) h = hashlib.sha1() h.update(auth_login.get()) login = h.hexdigest() h = hashlib.sha1() h.update(pwd) pw = h.hexdigest() checked = login + pw in content if checked: self.user = auth_login.get()[:] tkinter.messagebox.showinfo("Login success","Logged succesfuly as {0}".format(self.user)) if self.user == "admin": self.add_user_btn = ttk.Button(self.toolbar, text="add user", command=self.add_user) self.add_user_btn.pack(side="left") authTop.destroy() else: tkinter.messagebox.showerror("Login error", "Wrong login/password") except IOError: with codecs.open(".users", "w") as O: O.write("d033e22ae348aeb5660fc2140aec35850c4da997aee5aca44055f2cd2f2ce4266909b69a5d96dad2\n") print("Could not find .user file, rewriting it with admin user only.") authLabel = tkinter.Label(authTop, text="Enter credentials:") authLabel.grid(row=0, column=0, sticky=tkinter.W+tkinter.E, columnspan=2) tkinter.Label(authTop, text='login').grid(row=1, column=0, sticky=tkinter.W) auth_login_entry = tkinter.Entry(authTop, textvariable=auth_login) auth_login_entry.grid(row=1, column=1, sticky=tkinter.W) tkinter.Label(authTop, text='password').grid(row=2, column=0, sticky=tkinter.W) auth_pw_entry = tkinter.Entry(authTop, textvariable=auth_pw, show="*") auth_pw_entry.grid(row=2, column=1, sticky=tkinter.W) login_btn = ttk.Button(authTop, text="login", command=check_auth) login_btn.grid(row=3, column=0, sticky=tkinter.W+tkinter.E, columnspan=2)
Example #27
Source File: annotation_gui.py From SEM with MIT License | 4 votes |
def add_user(self, event=None): authTop = tkinter.Toplevel() authTop.grab_set() auth_login = tkinter.StringVar(authTop, value="admin") auth_pw = tkinter.StringVar(authTop, value="") def check_auth(): import hashlib pwd = auth_pw.get() if pwd == "": print("Please enter non empty password") return try: lines = [line.strip() for line in open(".users").readlines()] if "d033e22ae348aeb5660fc2140aec35850c4da997aee5aca44055f2cd2f2ce4266909b69a5d96dad2" not in lines: print("Something fishy about your .user file, rewriting it with admin user only.") with codecs.open(".users", "w") as O: O.write("d033e22ae348aeb5660fc2140aec35850c4da997aee5aca44055f2cd2f2ce4266909b69a5d96dad2\n") h = hashlib.sha1() h.update(auth_login.get()) login = h.hexdigest() h = hashlib.sha1() h.update(auth_pw.get()) pw = h.hexdigest() for line in lines: if line.startswith(login): tkinter.messagebox.showerror("Cannot add user", "User {0} already exists".format(auth_login.get())) return with codecs.open(".users", "a") as O: O.write("{0}{1}\n".format(login, pw)) tkinter.messagebox.showinfo("New user","Succesfuly added user {0}".format(auth_login.get())) authTop.destroy() except IOError: with codecs.open(".users", "w") as O: O.write("d033e22ae348aeb5660fc2140aec35850c4da997aee5aca44055f2cd2f2ce4266909b69a5d96dad2\n") print("Could not find .user file, rewriting it with admin user only.") authLabel = tkinter.Label(authTop, text="Enter credentials:") authLabel.grid(row=0, column=0, sticky=tkinter.W+tkinter.E, columnspan=2) tkinter.Label(authTop, text='login').grid(row=1, column=0, sticky=tkinter.W) auth_login_entry = tkinter.Entry(authTop, textvariable=auth_login) auth_login_entry.grid(row=1, column=1, sticky=tkinter.W) tkinter.Label(authTop, text='password').grid(row=2, column=0, sticky=tkinter.W) auth_pw_entry = tkinter.Entry(authTop, textvariable=auth_pw, show="*") auth_pw_entry.grid(row=2, column=1, sticky=tkinter.W) login_btn = ttk.Button(authTop, text="login", command=check_auth) login_btn.grid(row=3, column=0, sticky=tkinter.W+tkinter.E, columnspan=2) # # file menu methods #
Example #28
Source File: annotation_gui.py From SEM with MIT License | 4 votes |
def openurl(self, event=None): import urllib toplevel = tkinter.Toplevel() self.url = tkinter.StringVar() def cancel(event=None): self.url.set("") toplevel.destroy() def ok(event=None): document = sem.importers.from_url(self.url.get(), wikinews_format=bool(self.wikinews_format.get()), strip_html=True) if document is None: return added = self.add_document(document) if not added: return self.load_document() self.train_btn.configure(state=tkinter.NORMAL) self.file_menu.entryconfig("Save to...", state=tkinter.NORMAL) self.file_menu.entryconfig("Save as...", state=tkinter.NORMAL) cancel() label1 = tkinter.Label(toplevel, text="enter url:") label1.pack() text = ttk.Entry(toplevel, textvariable=self.url) text.pack() text.focus_set() c = ttk.Checkbutton(toplevel, text="Use Wikinews format", variable=self.wikinews_format) c.pack() toolbar = ttk.Frame(toplevel) toolbar.pack(side="top", fill="x") ok_btn = ttk.Button(toolbar, text="OK", command=ok) ok_btn.pack(side="left") cancel_btn = ttk.Button(toolbar, text="cancel", command=cancel) cancel_btn.pack(side="left") toplevel.bind('<Return>', ok) toplevel.bind('<Escape>', cancel) toolbar.pack()
Example #29
Source File: view.py From ms_deisotope with Apache License 2.0 | 4 votes |
def configure_display_row(self): self.display_row = ttk.Frame(self) self.display_row.grid(row=1, column=0, sticky=tk.W + tk.S + tk.E) self.cursor_label = ttk.Label(self.display_row, text=" " * 20) self.cursor_label.grid(row=0, padx=(10, 10)) def update_label(*args, **kwargs): self.cursor_label['text'] = self.canvas_cursor.binding.get() self.canvas_cursor.binding.trace('w', update_label) self.ms1_averagine_combobox = ttk.Combobox(self.display_row, values=[ "peptide", "glycan", "glycopeptide", "heparan sulfate", ], width=15) self.ms1_averagine_combobox.set("glycopeptide") self.ms1_averagine_combobox_label = ttk.Label(self.display_row, text="MS1 Averagine:") self.ms1_averagine_combobox_label.grid(row=0, column=1, padx=(10, 0)) self.ms1_averagine_combobox.grid(row=0, column=2, padx=(1, 10)) self.msn_averagine_combobox = ttk.Combobox(self.display_row, values=[ "peptide", "glycan", "glycopeptide", "heparan sulfate", ], width=15) self.msn_averagine_combobox.set("peptide") self.msn_averagine_combobox_label = ttk.Label(self.display_row, text="MSn Averagine:") self.msn_averagine_combobox_label.grid(row=0, column=3, padx=(10, 0)) self.msn_averagine_combobox.grid(row=0, column=4, padx=(1, 10)) self.ms1_scan_averaging_label = ttk.Label( self.display_row, text="MS1 Signal Averaging:") self.ms1_scan_averaging_label.grid(row=0, column=5, padx=(10, 0)) self.ms1_scan_averaging_var = tk.IntVar(self, value=2) self.ms1_scan_averaging = ttk.Entry(self.display_row, width=3) self.ms1_scan_averaging['textvariable'] = self.ms1_scan_averaging_var self.ms1_scan_averaging.grid(row=0, column=6, padx=(1, 3)) self.min_charge_state_var = tk.IntVar(self, value=1) self.max_charge_state_var = tk.IntVar(self, value=12) self.min_charge_state_label = ttk.Label( self.display_row, text="Min Charge:") self.min_charge_state_label.grid(row=0, column=7, padx=(5, 0)) self.min_charge_state = ttk.Entry(self.display_row, width=3) self.min_charge_state['textvariable'] = self.min_charge_state_var self.min_charge_state.grid(row=0, column=8, padx=(1, 3)) self.max_charge_state_label = ttk.Label( self.display_row, text="Max Charge:") self.max_charge_state_label.grid(row=0, column=9, padx=(5, 0)) self.max_charge_state = ttk.Entry(self.display_row, width=3) self.max_charge_state['textvariable'] = self.max_charge_state_var self.max_charge_state.grid(row=0, column=10, padx=(1, 3))
Example #30
Source File: PluginOptions.py From aurora-sdk-mac with Apache License 2.0 | 4 votes |
def create_int_plugin_option_row(self, pluginOptionType, pluginOptionFrame, pluginOptionTypeVar, row=-1, defaultVal=-1, minVal=-1, maxVal=-1): if not self.plugin_option_is_type_int(pluginOptionType): return if pluginOptionType == OPTION_TRANSTIME: if defaultVal == -1: defaultVal = 15 if minVal == -1: minVal = 1 if maxVal == -1: maxVal = 600 elif pluginOptionType == OPTION_DELAYTIME: if defaultVal == -1: defaultVal = 15 if minVal == -1: minVal = 0 if maxVal == -1: maxVal = 600 elif pluginOptionType == OPTION_WINDOWSIZE: if defaultVal == -1: defaultVal = 1 if minVal == -1: minVal = 1 if maxVal == -1: maxVal = 50 ttk.Label(pluginOptionFrame, text='Min Value:').grid(column=1, row=row, sticky=(E)) pluginOptionMinValue = StringVar() if minVal > -1: pluginOptionMinValue.set(minVal) ttk.Entry(pluginOptionFrame, width=5, textvariable=pluginOptionMinValue, justify='center').grid(column=2, row=row, sticky=(W)) ttk.Label(pluginOptionFrame, text='Max Value:').grid(column=3, row=row, sticky=(E)) pluginOptionMaxValue = StringVar() if maxVal > -1: pluginOptionMaxValue.set(maxVal) pluginOptionMaxElement = ttk.Entry(pluginOptionFrame, width=5, textvariable=pluginOptionMaxValue, justify='center').grid(column=4, row=row, sticky=(W)) ttk.Label(pluginOptionFrame, text=' ').grid(column=5, row=row) ttk.Label(pluginOptionFrame, text='Default Value:').grid(column=6, row=row, sticky=(E)) pluginOptionDefaultValue = StringVar() if defaultVal > -1: pluginOptionDefaultValue.set(defaultVal) ttk.Entry(pluginOptionFrame, width=5, textvariable=pluginOptionDefaultValue, justify='center').grid(column=7, row=row) pluginOptionRow = { "rowFrame": pluginOptionFrame, "optionTypeVar": pluginOptionTypeVar, "optionMinVar": pluginOptionMinValue, "optionMaxVar": pluginOptionMaxValue, "optionDefaultVar": pluginOptionDefaultValue } ttk.Button(pluginOptionFrame, text='Remove', command=lambda: self.remove_plugin_option(pluginOptionRow)).grid(column=8, row=row, sticky=(E)) return pluginOptionRow