本文整理汇总了Python中tkinter.N属性的典型用法代码示例。如果您正苦于以下问题:Python tkinter.N属性的具体用法?Python tkinter.N怎么用?Python tkinter.N使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类tkinter
的用法示例。
在下文中一共展示了tkinter.N属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_buttons
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def build_buttons(self):
btn_args = dict(
height=1,
)
btn_group = tk.Frame(self)
buttons = [
tk.Button(
btn_group,
text=text,
command=command,
**btn_args
)
for text, command in (
("开始下载", self.start_download),
("停止下载", self.stop_download),
("打开下载文件夹", self.open_download_folder),
)
]
for index, btn in enumerate(buttons):
btn.grid(column=index, row=0, sticky=tk.N)
btn_group.pack(fill=tk.BOTH, expand=1)
return btn_group
示例2: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def __init__(self):
super().__init__()
self.title("Blackjack")
self.geometry("800x640")
self.resizable(False, False)
self.bottom_frame = tk.Frame(self, width=800, height=140, bg="red")
self.bottom_frame.pack_propagate(0)
self.hit_button = tk.Button(self.bottom_frame, text="Hit", width=25, command=self.hit)
self.stick_button = tk.Button(self.bottom_frame, text="Stick", width=25, command=self.stick)
self.next_round_button = tk.Button(self.bottom_frame, text="Next Round", width=25, command=self.next_round)
self.quit_button = tk.Button(self.bottom_frame, text="Quit", width=25, command=self.destroy)
self.new_game_button = tk.Button(self.bottom_frame, text="New Game", width=25, command=self.new_game)
self.bottom_frame.pack(side=tk.BOTTOM, fill=tk.X)
self.game_screen = GameScreen(self, bg="white", width=800, height=500)
self.game_screen.pack(side=tk.LEFT, anchor=tk.N)
self.game_screen.setup_opening_animation()
示例3: create_window
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def create_window(self):
self.root.grid_rowconfigure(1,weight=1)
self.root.grid_columnconfigure(0,weight=1)
self.img_label = tk.Label(self.root)
self.img_label.configure(image=self.c_img)
self.hist_label = tk.Label(self.root)
self.hist_label.grid(row=0,column=0)
#self.img_label.pack(fill=tk.BOTH)
self.img_label.grid(row=1,column=0,
rowspan=len(self.camera.settings_dict)+2, sticky=tk.N+tk.E+tk.S+tk.W)
self.create_inputs()
self.create_infos()
self.img_label.bind('<Motion>', self.update_reticle)
self.img_label.bind('<4>', self.zoom_in)
self.img_label.bind('<5>', self.zoom_out)
self.root.bind('<MouseWheel>', self.zoom)
self.img_label.bind('<1>', self.start_move)
self.img_label.bind('<B1-Motion>', self.move)
示例4: configure_canvas
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def configure_canvas(self):
self.figure = Figure(dpi=100)
self.canvas = FigureCanvasTkAgg(self.figure, master=self)
self.axis = self.figure.add_subplot(111)
self.canvas.draw()
canvas_widget = self.canvas.get_tk_widget()
canvas_widget.grid(row=0, column=0, sticky=tk.N + tk.W + tk.E + tk.S)
self.canvas_cursor = Cursor(self.axis, tk.StringVar(master=self.root))
self.canvas.mpl_connect('motion_notify_event', self.canvas_cursor.mouse_move)
self.span = SpanSelector(
self.axis, self.zoom, 'horizontal', useblit=True,
rectprops=dict(alpha=0.5, facecolor='red'))
self.mz_span = None
self.scan = None
self.annotations = []
self.canvas.draw()
示例5: configure_treeview
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def configure_treeview(self):
self.treeview = ttk.Treeview(self)
self.treeview['columns'] = ["id", "time", 'ms_level', 'precursor_mz', 'precursor_charge', 'activation']
self.treeview.grid(row=2, column=0, sticky=tk.S + tk.W + tk.E + tk.N)
self.treeview_scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.treeview.yview)
self.treeview_scrollbar.grid(row=2, column=0, sticky=tk.S + tk.E + tk.N)
self.treeview.configure(yscrollcommand=self.treeview_scrollbar.set)
self.treeview.heading('id', text="Scan ID")
self.treeview.heading('#0', text='Index')
self.treeview.heading("time", text='Time (min)')
self.treeview.heading("ms_level", text='MS Level')
self.treeview.heading("precursor_mz", text='Precursor M/Z')
self.treeview.heading("precursor_charge", text='Precursor Z')
self.treeview.heading("activation", text='Activation')
self.treeview.column("#0", width=75)
self.treeview.column("ms_level", width=75)
self.treeview.column("time", width=75)
self.treeview.column("precursor_mz", width=100)
self.treeview.column("precursor_charge", width=100)
self.treeview.bind("<<TreeviewSelect>>", self.on_row_click)
示例6: table
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def table(self, master, title, content, target=None, backgroundcolour="White", foregroundcolour="black", bordercolour="grey", borderwidth=1, fontstyle="DejaVuSans 18 normal"):
# creates a table from a 2 dimensional array.
# master: = this represents the parent window
# content: a 2 dimensional array containing the table contents
# First column in the array must be the row id which is returned on a click event. This will not be displayed in the table
index = 0
for i in range(len(content)): #Rows
for j in range(len(content[i])):
if j==0:
index = content[i][j]
else:
b = tk.Label(master, text=str(content[i][j]), background=backgroundcolour, foreground=foregroundcolour,padx=5, pady=10, highlightthickness=borderwidth, highlightbackground=bordercolour, font=fontstyle)
if (target is not None):
b.bind('<ButtonPress-1>', self.__row_pressed)
b.bind('<ButtonRelease-1>', lambda event, arg1=index, arg2=target: self.__row_released(event, arg1, arg2))
b.grid(row=i, column=j-1, sticky=tk.N+tk.S+tk.E+tk.W)
return
示例7: _create_file_format_btn
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def _create_file_format_btn(self, btn_text, var_value, parent, column):
''' Creates and grids Radiobutton used for choosing solution file
format.
Args:
btn_text (str): text displayed next to the Radiobutton.
var_value (int): value of the IntVar associated with this
Radiobutton.
parent (Tk object): parent of this Radiobutton.
column (int): column index where this Radiobutton
should be gridded.
'''
sol_format_btn = Radiobutton(parent, text=btn_text,
variable=self.solution_format_var,
value=var_value)
sol_format_btn.grid(row=2, column=column, sticky=W+N, padx=2)
示例8: create_widgets
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def create_widgets(self):
''' Creates all widgets.
'''
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
xscrollbar = Scrollbar(self, orient=HORIZONTAL)
xscrollbar.grid(row=1, column=0, sticky=E+W)
yscrollbar = Scrollbar(self)
yscrollbar.grid(row=0, column=1, sticky=N+S)
self.text = Text(self, wrap=NONE,
xscrollcommand=xscrollbar.set,
yscrollcommand=yscrollbar.set)
self.text.bind("<Control-Key-a>", self.select_all)
self.text.bind("<Control-Key-A>", self.select_all)
self.text.grid(row=0, column=0, sticky=N+S+E+W)
xscrollbar.config(command=self.text.xview)
yscrollbar.config(command=self.text.yview)
示例9: create_widgets
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def create_widgets(self, names):
''' Creates appropriate widgets.
Args:
names (list of str): list of available sheet names.
'''
sheet_name_lbl = Label(self,
text='Choose sheet name where data is stored:')
sheet_name_lbl.grid(sticky=N+W, padx=5, pady=5)
sheet_names_box = Combobox(self, state="readonly", width=20,
textvariable=self.sheet_name_str,
values=names)
sheet_names_box.current(0)
sheet_names_box.grid(row=1, column=0, columnspan=2,
sticky=N+W, padx=5, pady=5)
ok_btn = Button(self, text='OK', command=self.ok)
ok_btn.grid(row=2, column=0, sticky=N+E, padx=5, pady=5)
ok_btn.bind('<Return>', self.ok)
ok_btn.focus()
cancel_btn = Button(self, text='Cancel', command=self.cancel)
cancel_btn.grid(row=2, column=1, sticky=N+E, padx=5, pady=5)
cancel_btn.bind('<Return>', self.cancel)
示例10: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def __init__( self, parent, scale, historySize, trackColors, *args, **opts ):
# Initialize
super().__init__( parent, *args, **opts )
self._trackHist = OrderedDict() # Map: TrackName -> list of canvas objID
self._trackColor = trackColors # Map: Track Name -> color
self._chartHeight = scale + 1
self._chartLength = historySize * 2 # Stretch for readability
self._canvas = tk.Canvas( self, height=self._chartHeight + 17,
width=self._chartLength, background='black' )
self._canvas.grid( sticky=tk.N+tk.S+tk.E+tk.W )
# Draw horizontal to divide plot from tick labels
x, y = 0, self._chartHeight + 2
x2, y2 = self._chartLength, y
self._baseLine = self._canvas.create_line( x, y, x2, y2, fill='white' )
# Init track def and histories lists
self._trackColor.update( { 'tick':'white', 'tickline':'white',
'ticklabel':'white' } )
for trackName in self._trackColor.keys():
self._trackHist[ trackName ] = [ None for x in range(historySize) ]
示例11: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def __init__(self, root, imagesList, final_img_size):
super(SliderGalleryFrame, self).__init__(root)
self.master.minsize(width=100, height=100)
self.master.config()
self.master.bind('<Left>', self.left_key)
self.master.bind('<Right>', self.right_key)
self.main_frame = tk.Frame()
self.main_frame.pack(fill='both', expand=True)
self.imagesList = imagesList
self.panel = tk.Label(root, image=self.imagesList[0])
self.panel.pack(side="bottom", fill="both", expand="yes")
self.var = tk.IntVar()
self.scale = tk.Scale(root, from_=0, to=len(imagesList) - 1, variable=self.var, orient=tk.HORIZONTAL,
command=self.sel, width=20, length=final_img_size)
self.scale.pack(anchor=tk.N)
self.pack()
示例12: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def __init__(self, frame):
self.frame = frame
# Create a ScrolledText wdiget
self.scrolled_text = ScrolledText(frame, state='disabled', height=12)
self.scrolled_text.grid(row=0, column=0, sticky=(N, S, W, E))
self.scrolled_text.configure(font='TkFixedFont')
self.scrolled_text.tag_config('INFO', foreground='black')
self.scrolled_text.tag_config('DEBUG', foreground='gray')
self.scrolled_text.tag_config('WARNING', foreground='orange')
self.scrolled_text.tag_config('ERROR', foreground='red')
self.scrolled_text.tag_config('CRITICAL', foreground='red', underline=1)
# Create a logging handler using a queue
self.log_queue = queue.Queue()
self.queue_handler = QueueHandler(self.log_queue)
formatter = logging.Formatter('%(asctime)s: %(message)s')
self.queue_handler.setFormatter(formatter)
logger.addHandler(self.queue_handler)
# Start polling messages from the queue
self.frame.after(100, self.poll_log_queue)
示例13: _color_control
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def _color_control(self):
""" Clickable label holding the currently selected color """
logger.debug("Add control to Options Frame: (widget: '%s', control: %s, choices: %s)",
self.option.name, self.option.control, self.option.choices)
frame = ttk.Frame(self.frame)
ctl = tk.Frame(frame,
bg=self.option.default,
bd=2,
cursor="hand2",
relief=tk.SUNKEN,
width=round(int(20 * get_config().scaling_factor)),
height=round(int(12 * get_config().scaling_factor)))
ctl.bind("<Button-1>", lambda *e, c=ctl, t=self.option.title: self._ask_color(c, t))
ctl.pack(side=tk.LEFT, anchor=tk.W)
lbl = ttk.Label(frame, text=self.option.title, width=self.label_width, anchor=tk.W)
lbl.pack(padx=2, pady=5, side=tk.RIGHT, anchor=tk.N)
frame.pack(side=tk.LEFT, anchor=tk.W)
if self.option.helptext is not None:
_get_tooltip(lbl, text=self.option.helptext, wraplength=600)
logger.debug("Added control to Options Frame: %s", self.option.name)
return ctl
示例14: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def __init__(self, parent, available_masks, has_predicted_mask, selected_color,
selected_mask_type, selected_scaling, config_tools, patch_callback,
refresh_callback, tk_vars):
logger.debug("Initializing %s: (available_masks: %s, has_predicted_mask: %s, "
"selected_color: %s, selected_mask_type: %s, selected_scaling: %s, "
"patch_callback: %s, refresh_callback: %s, tk_vars: %s)",
self.__class__.__name__, available_masks, has_predicted_mask, selected_color,
selected_mask_type, selected_scaling, patch_callback, refresh_callback,
tk_vars)
self._config_tools = config_tools
super().__init__(parent)
self.pack(side=tk.LEFT, anchor=tk.N, fill=tk.Y)
self._options = ["color", "mask_type", "scaling"]
self._busy_tkvar = tk_vars["busy"]
self._tk_vars = dict()
d_locals = locals()
defaults = {opt: self._format_to_display(d_locals["selected_{}".format(opt)])
for opt in self._options}
self._busy_indicator = self._build_frame(defaults,
refresh_callback,
patch_callback,
available_masks,
has_predicted_mask)
示例15: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import N [as 别名]
def __init__(self, root, label, row, col):
tkinter.Frame.__init__(self, root, bg='#cecece')
# Set non-zero weight.
root.columnconfigure(col, weight=1)
root.rowconfigure(row, weight=1)
# Information being displayed.
self.label_text = label
self.info = ''
# Set up label.
text = '{0}: {1}'.format(self.label_text, self.info)
self.label = tkinter.Label(
self,
text=text,
bg='#cecece'
)
self.label.place(relx=0.5, rely=0.5, anchor='c')
# Position frame.
self.grid(
row=row,
column=col,
sticky=tkinter.N + tkinter.S + tkinter.E + tkinter.W
)
# Update info.