我们从Python开源项目中,提取了以下20个代码示例,用于说明如何使用tkinter.ttk.Separator()。
def __init__(self, parent, expanded_text="Collapse <<", collapsed_text="Expand >>", *args): ttk.Frame.__init__(self, parent, *args) self.parent = parent self._expanded_text = expanded_text self._collapsed_text = collapsed_text self.columnconfigure(1, weight=1) self._variable = tk.IntVar() self._button = ttk.Checkbutton(self, variable=self._variable, command=self._activate, style="TButton") self._button.grid(row=0, column=0) self._separator = ttk.Separator(self, orient="horizontal") self._separator.grid(row=0, column=1, sticky="we") self.frame = ttk.Frame(self) self._activate()
def __init__(self, parent, text="", orient="horizontal", text_align="", padding=5, *args): ttk.Frame.__init__(self, parent, *args) self.parent = parent self._text = text self._orient = orient self._text_align = text_align self._padding = padding self._separator = ttk.Separator(self, orient=self._orient) self._label = ttk.Label(self, text=self._text) if self._orient == "horizontal": self.grid_columnconfigure(0, weight=1) self._separator.grid(row=0, column=0, sticky="we") self._label.grid(row=0, column=0, sticky=self._text_align, padx=self._padding) elif self._orient == "vertical": self.grid_rowconfigure(0, weight=1) self._separator.grid(row=0, column=0, sticky="ns") self._label.grid(row=0, column=0, sticky=self._text_align, pady=self._padding) ##################################################
def __init__(self, parent, *args, **kwargs): ttk.Frame.__init__(self, parent, *args, **kwargs) self.parent = parent self.columnconfigure(6, weight=1) # self.widget_button_undo = ttk.Button(self, text="Undo", style="Toolbutton") # self.widget_button_undo.grid(row=0, column=0) # self.widget_button_redo = ttk.Button(self, text="Redo", style="Toolbutton") # self.widget_button_redo.grid(row=0, column=1) # ttk.Separator(self, orient="vertical").grid(row=0, column=2, sticky="ns") self.widget_button_refresh = ttk.Button(self, text="Refresh", image=self.parent.image_refresh, command=self.parent.cmd.tree_refresh, style="Toolbutton") self.widget_button_refresh.grid(row=0, column=3) idlelib.ToolTip.ToolTip(self.widget_button_refresh, "Refresh the files in the TreeView") self.widget_entry_search = ttk.Entry(self) self.widget_entry_search.grid(row=0, column=6, sticky="we") # self.widget_button_previous = ttk.Button(self, text="Previous", state="disabled") # self.widget_button_previous.grid(row=0, column=7) # # self.widget_button_next = ttk.Button(self, text="Next", state="disabled") # self.widget_button_next.grid(row=0, column=8) self.widget_button_search = ttk.Button(self, text="Search", command=self.parent.cmd.search) self.widget_button_search.grid(row=0, column=9) idlelib.ToolTip.ToolTip(self.widget_button_search, "Search the TreeView for a file") self.widget_button_exit = ttk.Button(self, text="Exit", image=self.parent.image_exit, command=sys.exit, style="Toolbutton") self.widget_button_exit.grid(row=0, column=10, sticky="e") idlelib.ToolTip.ToolTip(self.widget_button_exit, "Exit the program")
def __init__(self, parent, title="Dialog", transient=True, resizable=(False, False), geometry="300x300", separator=False, background="white", *args, **kwargs): tk.Toplevel.__init__(self, parent) self.parent = parent self.title(title) ttk.Style().configure("White.TFrame", background=background) frame = ttk.Frame(self, style="White.TFrame") self.initial_focus = self.body(frame) frame.pack(fill="both", expand=True) if separator: ttk.Separator(self).pack(fill="x") self.buttonbox() self.update() if transient: self.transient(self.parent) if geometry: self.geometry(geometry) if resizable: self.resizable(resizable[0], resizable[1]) pk.center_on_parent(self) self.grab_set()
def __init__(self, parent, *args, **kwargs): ttk.Frame.__init__(self, parent, *args, **kwargs) self.parent = parent self.is_text_valid = False self.search_entry = SearchEntry(self, replace=True) self.search_entry.pack(side="left") ttk.Separator(self, orient="vertical").pack(side="left", fill="y", padx=3, pady=1) self.button_replace = ttk.Button(self, text="Replace", command=self.parent.master.replace) self.button_replace.pack(side="left") self.button_replace_all = ttk.Button(self, text="Replace All", command=self.parent.master.replace_all) self.button_replace_all.pack(side="left")
def create(self, **kwargs): return ttk.Separator(self.root, **kwargs)
def __init__(self, parent, label_text="", accelerator_text="", has_separator=False, *args): ttk.Frame.__init__(self, parent, *args) self.parent = parent self._label_text = label_text self._accelerator_text = accelerator_text self._has_separator = has_separator self._label = ttk.Label(self, text=self._label_text).pack(side="left", fill="x") self._accelerator = ttk.Label(self, text=self._accelerator_text).pack(side="right") if self._has_separator: self._separator = ttk.Separator(self, orient="vertical").pack(side="right", fill="y") ##################################################
def add_separator(self, side="left"): """Adds a Separator to the Toolbar.""" widget = ttk.Separator(self, orient="vertical") widget.pack(side=side, fill="y", padx=3, pady=1) return widget ##################################################
def add_separator(self, side="left"): """Adds a Separator to the Statusbar.""" widget = ttk.Separator(self, orient="vertical") widget.pack(side=side, fill="y", padx=3, pady=1) return widget
def makeframe(): global frame_open global app_frame global explorer_button global browser_button global quickpad_button global list_apps_open global list_scripts_open console.reload_scripts() console.reload_apps() if not frame_open: # apps_button.configure(text='Applications [X]') app_frame = LabelFrame() app_frame.place(anchor=SW, relx=0, x=5, rely=1, y=-30) Button(app_frame, text='Apps >', relief=FLAT, width=13, cursor='hand2', command=list_bin).pack(side=BOTTOM, fill=X) Button(app_frame, text='Scripts >', relief=FLAT, cursor='hand2', command=list_scripts).pack(side=BOTTOM, fill=X) ttk.Separator(app_frame, orient=HORIZONTAL).pack(side=BOTTOM, fill=X) # Tabs quickpad_button = Button(app_frame, textvariable=quickpad_app, cursor='hand2', command=disable_3) quickpad_button.pack(side=BOTTOM, fill=X) browser_button = Button(app_frame, textvariable=browser_app, cursor='hand2', command=disable_2) browser_button.pack(side=BOTTOM, fill=X) explorer_button = Button(app_frame, textvariable=explorer_app, cursor='hand2', command=disable_1) explorer_button.pack(side=BOTTOM, fill=X) frame_open = True else: # apps_button.configure(text='Applications') if list_apps_open: apps_list.destroy() list_apps_open = False if list_scripts_open: scripts_list.destroy() list_scripts_open = False app_frame.destroy() frame_open = False
def insert_ttk_separator(self, orient: str="horizontal", index: int or str="end", **kwargs): """Insert a ttk.Separator into the game.""" widget = ttk.Separator(self.text, orient=orient, **kwargs) self.text.window_create(index, window=widget) return widget
def insert_ttk_treeview(self, columns: list=[], displaycolumns: list or str="#all", height: int=None, padding: list=[], selectmode: str="extended", show: str="tree headings", index: int or str="end", **kwargs): """Insert a ttk.Separator into the game.""" widget = ttk.Treeview(self.text, columns=columns, displaycolumns=displaycolumns, height=height, padding=padding, selectmode=selectmode, show=show, **kwargs) self.text.window_create(index, window=widget) return widget # Bind Functions
def __init__(self, parent, **kwargs): ttk.Frame.__init__(self, parent, **kwargs) self.parent = parent # TODO: Change this to a pk.Toolbar. image = load_images.LoadImages() self.image_chessboard = image.image_chessboard self.image_grid = image.image_grid self.image_zoom_in = image.image_zoom_in self.image_zoom_out = image.image_zoom_out self.variable_chessboard = tk.BooleanVar() self.variable_chessboard.set(True) self.widget_check_chessboard = ttk.Checkbutton(self, text="Chessboard", image=self.image_chessboard, variable=self.variable_chessboard, command=self.parent.draw_background, style="Toolbutton") self.widget_check_chessboard.grid(row=0, column=0) self.variable_grid = tk.BooleanVar() self.variable_grid.set(False) self.widget_check_grid = ttk.Checkbutton(self, text="Grid", image=self.image_grid, variable=self.variable_grid, command=self.parent.draw_background, style="Toolbutton") self.widget_check_grid.grid(row=0, column=1) ttk.Separator(self, orient="vertical").grid(row=0, column=2, sticky="ns") self.widget_button_zoom_in = ttk.Button(self, text="Zoom In", image=self.image_zoom_in, command=self.parent.zoom_in, style="Toolbutton") self.widget_button_zoom_in.grid(row=0, column=3) self.widget_button_zoom_out = ttk.Button(self, text="Zoom Out", image=self.image_zoom_out, command=self.parent.zoom_out, style="Toolbutton") self.widget_button_zoom_out.grid(row=0, column=4) idlelib.ToolTip.ToolTip(self.widget_button_zoom_out, "Zoom the image out") ttk.Separator(self, orient="vertical").grid(row=0, column=5, sticky="ns") self.variable_tile = tk.BooleanVar() self.widget_button_tile = ttk.Checkbutton(self, text="Tile", variable=self.variable_tile, command=self.parent.check_tile_buttons, style="Toolbutton") self.widget_button_tile.grid(row=0, column=6) self.variable_tile_sides = tk.BooleanVar() self.widget_button_tile_sides = ttk.Checkbutton(self, text="Tile Side", variable=self.variable_tile_sides, command=self.parent.draw_tiles, style="Toolbutton") self.widget_button_tile_sides.grid(row=0, column=7) self.variable_tile_corners = tk.BooleanVar() self.widget_button_tile_corners = ttk.Checkbutton(self, text="Tile Corners", variable=self.variable_tile_corners, command=self.parent.draw_tiles, style="Toolbutton") self.widget_button_tile_corners.grid(row=0, column=8)
def __init__(self, parent, *args, **kwargs): ttk.Frame.__init__(self, parent, *args, **kwargs) self.parent = parent self.is_text_valid = False self.search_entry = SearchEntry(self) self.search_entry.pack(side="left") ttk.Separator(self, orient="vertical").pack(side="left", fill="y", padx=3, pady=1) self.button_previous = ttk.Button(self, text="Previous", image=self.parent.master.image_find_previous, command=lambda: self.parent.master.search(previous=True, match_case=not self.variable_match_case.get(), exact=not self.variable_exact.get(), regular_expression=not self.variable_regular_expression.get())) self.button_previous.pack(side="left") self.button_next = ttk.Button(self, text="Next", image=self.parent.master.image_find_next, command=lambda: self.parent.master.search(next_=True, match_case=not self.variable_match_case.get(), exact=not self.variable_exact.get(), regular_expression=not self.variable_regular_expression.get())) self.button_next.pack(side="left") self.button_find_all = ttk.Button(self, text="Find All", command=self.parent.master.search_all) self.button_find_all.pack(side="left") ttk.Separator(self, orient="vertical").pack(side="left", fill="y", padx=3, pady=1) self.variable_match_case = tk.BooleanVar(value=0) self.checkbutton_match_case = ttk.Checkbutton(self, text="Match Case", variable=self.variable_match_case) self.checkbutton_match_case.pack(side="left") self.variable_exact = tk.BooleanVar(value=0) self.checkbutton_exact = ttk.Checkbutton(self, text="Exact", variable=self.variable_exact) self.checkbutton_exact.pack(side="left") self.variable_regular_expression = tk.BooleanVar(value=0) self.checkbutton_regular_expression = ttk.Checkbutton(self, text="Regular Expression", variable=self.variable_regular_expression) self.checkbutton_regular_expression.pack(side="left") self.search_entry.check_search()
def __init__(self, parent, ID, elevationEditor, elevationProfile=None, bg="#6090CC"): tk.Frame.__init__(self, parent, relief='groove', bd=2) self.columnconfigure(0, weight=1) self.col_bg = bg self.labelFont = tkFont.Font(family="Helvetica", size=8) self.expanded = False self.expFrame = None self.eleditor = elevationEditor self.ID = 'elevationProfile%d' %ID self.ep = elevationProfile self.filename = self.ep['filename'] self.data = self.ep['data'] self._first_x = self.data[0][0] self._first_z = self.data[0][1] self.outputdata = None self.pathfitting = tk.StringVar(value='None') self.joint_mode = tk.StringVar(value='None') self.x_offset = tk.DoubleVar(value=0) self.z_offset = tk.DoubleVar(value=0) self._repeat = tk.BooleanVar(value=False) self._display = tk.BooleanVar(value=True) #collapsed UI f = tk.Frame(self) f.columnconfigure(1, weight=1) f.grid(sticky='we') here = os.path.dirname(__file__) self.expandButton = IconButton(f, os.path.join(here, 'Icons', 'folded.gif'), command=self.expandToggle) self.expandButton.grid(row=0, column=0, padx=2) l = tk.Label(f, text=self.title(), font=self.labelFont, anchor='w') l.grid(row=0, column=1, sticky='we') b = IconButton(f, os.path.join(here, 'Icons', 'xicon.gif'), command=self.close) b.grid(row=0, column=2, padx=2) sep = ttk.Separator(self, orient=tk.HORIZONTAL) sep.grid(padx=2, sticky='we') #draw guide self.draw()
def expand(self): self.expFrame = f = tk.Frame(self) f.columnconfigure(0, weight=1) f.grid(sticky='we') f1 = tk.Frame(f) f1.columnconfigure(1, weight=1) f1.grid(sticky='we') labels = ['Path-fitting', 'Auto-rejoin', 'Offset x', 'Offset z', 'Repeat'] for row, text in enumerate(labels): l = tk.Label(f1, text=text, font=self.labelFont, anchor='w') l.grid(row=row, column = 0, sticky='we') PF = ttk.Combobox(f1, takefocus=False, width=6, font=self.labelFont, textvariable = self.pathfitting, values=('None', 'Stretch', 'Scale'), state="readonly") PF.grid(row=0, column = 1, sticky='we') PF.bind("<<ComboboxSelected>>", self.draw) JM = ttk.Combobox(f1, takefocus=False, width=6, font=self.labelFont, textvariable = self.joint_mode, values=('None', 'Lift', 'Bend'), state="readonly") JM.grid(row=1, column = 1, sticky='we') JM.bind("<<ComboboxSelected>>", self.draw) OS_x = FloatEntry(f1, textvariable = self.x_offset, font=self.labelFont, width=5) OS_x.grid(row=2, column = 1, sticky='we') OS_x.bind('<Return>', self.draw) OS_x.bind('<FocusOut>', self.draw) OS_z = FloatEntry(f1, textvariable = self.z_offset, font=self.labelFont, width=5) OS_z.grid(row=3, column = 1, sticky='we') OS_z.bind('<Return>', self.draw) OS_z.bind('<FocusOut>', self.draw) RP = tk.Checkbutton(f1, variable=self._repeat, command=self.draw) RP.grid(row=4, column = 1, sticky='w') sep = ttk.Separator(f, orient=tk.HORIZONTAL) sep.grid(padx=2, sticky='we') f2 = tk.Frame(f) for i in range(0, 3): f2.columnconfigure(i, weight=1) f2.grid(sticky='we') DS = tk.Checkbutton(f2, text='Display', width=5, font=self.labelFont, indicatoron=False, bd=1, variable=self._display, command=self.draw) DS.grid(row=0, column=0, sticky='wens', pady=2, padx=1) self.SET = tk.Button(f2, text='Set', width=5, font=self.labelFont, bd=1, command=self.applyCommand) self.SET.grid(row=0, column=1, sticky='we', pady=2, padx=1) self.ADD = tk.Button(f2, text='Add', width=5, font=self.labelFont, bd=1, command = lambda: self.applyCommand(mode='add')) self.ADD.grid(row=0, column=2, sticky='we', pady=2, padx=1)
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')