我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用ttk.Separator()。
def pack(self, **kwargs): tk.Frame.pack(self, **kwargs) self.frame.pack(fill=tk.BOTH, anchor=tk.CENTER, expand=True, pady=(0, 1)) self.capture.pack(side=tk.LEFT, padx=(6, 3)) self.stop.pack(side=tk.LEFT, padx=3) ttk.Separator(self.frame, orient=tk.VERTICAL).pack(side=tk.LEFT, fill=tk.Y, padx=3) self.open.pack(side=tk.LEFT, padx=3) self.save.pack(side=tk.LEFT, padx=3) self.pcap.pack(side=tk.LEFT, padx=3) self.export.pack(side=tk.LEFT, padx=3, pady=1) ttk.Separator(self.frame, orient=tk.VERTICAL).pack(side=tk.LEFT, fill=tk.Y, padx=3) self.search.pack(side=tk.LEFT, fill=tk.BOTH, padx=(3, 15), pady=3, expand=True) self.apply.pack(side=tk.LEFT, anchor=tk.E) self.clear.pack(side=tk.LEFT, anchor=tk.E, expand=False, padx=15)
def create(self, **kwargs): return ttk.Separator(self.root, **kwargs)
def plugin_prefs(parent): PADX = 5 global row row = 0 def nextRow(): global row row += 1 return row frame = nb.Frame(parent) frame.columnconfigure(1, weight=1) nb.Label(frame, text="Search Radius in Ly:").grid(row=0, column=0, padx=PADX, pady=(8,0), sticky=tk.W) nb.Label(frame, text="Update Every x Jumps:").grid(row=0, column=1, padx=PADX, pady=(8,0), sticky=tk.W) row = rowInterval = 1 values = sorted(OPTIONS_RADIUS.keys()) for value in values: nb.Radiobutton(frame, variable=this.radius, value=value, text=str(OPTIONS_RADIUS.get(value, ""))).grid(row=row, column=0, padx=PADX*4, sticky=tk.EW) row += 1 values = sorted(OPTIONS_INTERVAL.keys()) for value in values: nb.Radiobutton(frame, variable=this.updateInterval, value=value, text=str(OPTIONS_INTERVAL.get(value, ""))).grid(row=rowInterval, column=1, padx=PADX*4, sticky=tk.EW) rowInterval += 1 nb.Label(frame).grid(row=nextRow()) #spacer nb.Checkbutton(frame, variable=this.clipboard, text="Copy system name to clipboard").grid(row=nextRow(), column=0, columnspan=2, padx=PADX, sticky=tk.W) nb.Checkbutton(frame, variable=this.overwrite, text="I use another tool to transmit data to EDSM/EDDN").grid(row=nextRow(), column=0, columnspan=2, padx=PADX, sticky=tk.W) ttk.Separator(frame, orient=tk.HORIZONTAL).grid(row=nextRow(), columnspan=2, padx=PADX*2, pady=8, sticky=tk.EW) nb.Label(frame, text="Plugin Version: {}".format(VERSION)).grid(row=nextRow(), column=0, columnspan=2, padx=PADX, sticky=tk.W) nb.Label(frame, text="Database created: {}".format(datetime.fromtimestamp(this.dbVersion))).grid(row=nextRow(), column=0, columnspan=2, padx=PADX, sticky=tk.W) HyperlinkLabel(frame, text="Open the Github page for this plugin", background=nb.Label().cget("background"), url="https://github.com/Thurion/EDSM-RSE-for-EDMC", underline=True).grid(row=nextRow(), column=0, columnspan=2, padx=PADX, sticky=tk.W) HyperlinkLabel(frame, text="A big thanks to EDTS for providing the coordinates.", background=nb.Label().cget("background"), url="http://edts.thargoid.space/", underline=True).grid(row=nextRow(), column=0, columnspan=2, padx=PADX, sticky=tk.W) return frame
def __new__(cls, master, cmd_ok, cmd_save, cmd_cancel): w = tk.Toplevel(master) w.master = master w.title('Unsaved Packets...') w.geometry('360x120+%i+%i' % (master.winfo_rootx() + master.winfo_width() / 2 - 180, master.winfo_rooty() + master.winfo_height() / 2 - 120)) w.resizable(False, False) icon = tk.PhotoImage(file='../CF_small.gif') w.tk.call('wm', 'iconphoto', w._w, icon) w.protocol('WM_DELETE_WINDOW', w.destroy) CODE = 0 def ok(_=None): w.master.focus_set() w.destroy() cmd_ok() def cancel(_=None): w.master.focus_set() w.destroy() cmd_cancel() def save(): filename = tkFileDialog.asksaveasfilename(title='Save As', **w.filedialog_opts) if filename: w.master.focus_set() w.destroy() cmd_save(filename) def quit(code): master.focus_set() w.destroy() tk.Label(w, text='If You Don\'t Save, Your Capture Data Will Be Lost.\n Discard Unsaved Packets?', justify=tk.LEFT).pack(pady=15) ttk.Separator(w, orient=tk.HORIZONTAL).pack(fill=tk.X) frame = tk.Frame(w, bg='#D9D9D9') frame.pack(side=tk.BOTTOM, fill=tk.BOTH) tk.Button(frame, text=' Cancel ', command=cancel, bg='#D9D9D9') \ .pack(anchor=tk.S, side=tk.RIGHT, padx=(2, 4), pady=5) tk.Button(frame, text=' Save Packets ', bg='#D9D9D9', command=save) \ .pack(anchor=tk.S, side=tk.RIGHT, padx=2, pady=5) tk.Button(frame, text=' OK ', bg='#D9D9D9', command=ok) \ .pack(anchor=tk.S, side=tk.RIGHT, padx=2, pady=5) w.focus_set() w.grab_set() w.filedialog_opts = { 'parent': master, 'filetypes': [('cablefish files', '.cf'), ('all files', '.*')], 'initialdir': 'C:/Users/', 'defaultextension': '.banana' } master.wait_window(w)
def pack(self): ttk.Separator(self, orient=tk.HORIZONTAL).pack(fill=tk.X) # self.menubar.pack(fill=tk.BOTH) self.capture_menu.pack(fill=tk.X, side=tk.TOP) self.window.pack(fill=tk.BOTH, expand=True) self.hints.pack() self.packets_panel.pack() self.title('Cablefish') icon = tk.PhotoImage(file='CF_small.gif') self.tk.call('wm', 'iconphoto', self._w, icon) self.geometry('1000x600') self.protocol('WM_DELETE_WINDOW', self.app.quit) self.update()
def __init__(self, parent, root): ttk.Frame.__init__(self, parent) self.parent = parent self.root = root self['borderwidth'] = 2 self['relief'] = 'sunken' COMlabel = ttk.Label(self, text= \ self.root.variables['COMport'][0:5].strip() + ':') baudLabel = ttk.Label(self, text= \ str(self.root.variables['baud'].strip())) COMlabel.pack(side='left', padx=0) baudLabel.pack(side='left', padx=0) ttk.Separator(self, orient='vertical').pack(side='left', fill='y', padx=5) buffLabel = ttk.Label(self, text='Serial Buffer:') buffLabel.pack(side='left', padx=0) buffBar = ttk.Progressbar(self, orient='horizontal', length=50,\ mode='determinate', variable=self.root.variables['buffsize'],\ maximum=io.DEFAULT_BUFFER_SIZE) buffBar.pack(side='left') ttk.Separator(self, orient='vertical').pack(side='left', fill='y', padx=5) lastLabel = ttk.Label(self, text='Last line Recieved: ') lastLabel.pack(side='left') lastLine = ttk.Label(self, textvariable=self.root.variables['lastline'], \ font=('Courier', 8)) lastLine.pack(side='left') ttk.Separator(self, orient='vertical').pack(side='left', fill='y', padx=5) updateLabel = ttk.Label(self, text='Data Recieved at: ') updateLabel.pack(side='left') updateRate = ttk.Label(self, textvariable=self.root.variables['refreshrate']) updateRate.pack(side='left') ttk.Label(self, text='Hz (Est)').pack(side='left') ttk.Separator(self, orient='vertical').pack(side='left', fill='y', padx=5) if self.root.variables['log2file'] == 'on': self.root.toggleLogButton = ttk.Button(self, text='Turn Logging Off', command = self.toggleLog) self.root.toggleLogButton.pack(side='left')