本文整理汇总了Python中six.moves.tkinter.Frame.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.__init__方法的具体用法?Python Frame.__init__怎么用?Python Frame.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类six.moves.tkinter.Frame
的用法示例。
在下文中一共展示了Frame.__init__方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import __init__ [as 别名]
def __init__(self, *args, **kwargs):
Frame.__init__(self, *args, **kwargs)
self.__label = Label(self)
self.__label.pack(side=LEFT)
self.__entry = Entry(self)
self.__entry.pack(fill=X, expand=YES)
self.__checker_function = None
self.__image = None
示例2: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import __init__ [as 别名]
def __init__(self, master):
'''Create the UI for a game of battleship.'''
Frame.__init__(self, master)
self._create_ui()
# these are 'controller' elements that should really be in another class
self.ai = ShipAI(self.their_grid._model, self.my_grid._model)
self.reset()
示例3: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import __init__ [as 别名]
def __init__(self, *args, **kwargs):
Frame.__init__(self, *args, **kwargs)
Observable.__init__(self)
self._text = text = Text(self, wrap=NONE, height=1.2, relief=SOLID)
text.bind('<Configure>', self._on_resize)
text.bind('<KeyPress>', self._on_key_press)
text.pack(fill=X, expand=YES, side=LEFT)
self._default_cursor = text['cursor']
self._default_background_color = text['background']
# Browse Button
text.tag_config('browse_button', foreground='orange')
text.tag_bind('browse_button', '<Button-1>', self._on_button_click)
text.tag_bind('browse_button', '<Enter>',
lambda *args: self._change_cursor_to_hand(True))
text.tag_bind('browse_button', '<Leave>',
lambda *args: self._change_cursor_to_hand(False))
# End Browse Button
self._blank_len = 2
self._browse_text = 'BROWSE'
self._coding = sys.getfilesystemencoding()
self._directory = None
示例4: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import __init__ [as 别名]
def __init__(self, master):
Frame.__init__(self, master)
示例5: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import __init__ [as 别名]
def __init__(self, master, columns, column_weights=None, cnf={}, **kw):
"""
Construct a new multi-column listbox widget.
:param master: The widget that should contain the new
multi-column listbox.
:param columns: Specifies what columns should be included in
the new multi-column listbox. If ``columns`` is an integer,
the it is the number of columns to include. If it is
a list, then its length indicates the number of columns
to include; and each element of the list will be used as
a label for the corresponding column.
:param cnf, kw: Configuration parameters for this widget.
Use ``label_*`` to configure all labels; and ``listbox_*``
to configure all listboxes. E.g.:
>>> mlb = MultiListbox(master, 5, label_foreground='red')
"""
# If columns was specified as an int, convert it to a list.
if isinstance(columns, int):
columns = list(range(columns))
include_labels = False
else:
include_labels = True
if len(columns) == 0:
raise ValueError("Expected at least one column")
# Instance variables
self._column_names = tuple(columns)
self._listboxes = []
self._labels = []
# Pick a default value for column_weights, if none was specified.
if column_weights is None:
column_weights = [1] * len(columns)
elif len(column_weights) != len(columns):
raise ValueError('Expected one column_weight for each column')
self._column_weights = column_weights
# Configure our widgets.
Frame.__init__(self, master, **self.FRAME_CONFIG)
self.grid_rowconfigure(1, weight=1)
for i, label in enumerate(self._column_names):
self.grid_columnconfigure(i, weight=column_weights[i])
# Create a label for the column
if include_labels:
l = Label(self, text=label, **self.LABEL_CONFIG)
self._labels.append(l)
l.grid(column=i, row=0, sticky='news', padx=0, pady=0)
l.column_index = i
# Create a listbox for the column
lb = Listbox(self, **self.LISTBOX_CONFIG)
self._listboxes.append(lb)
lb.grid(column=i, row=1, sticky='news', padx=0, pady=0)
lb.column_index = i
# Clicking or dragging selects:
lb.bind('<Button-1>', self._select)
lb.bind('<B1-Motion>', self._select)
# Scroll whell scrolls:
lb.bind('<Button-4>', lambda e: self._scroll(-1))
lb.bind('<Button-5>', lambda e: self._scroll(+1))
lb.bind('<MouseWheel>', lambda e: self._scroll(e.delta))
# Button 2 can be used to scan:
lb.bind('<Button-2>', lambda e: self.scan_mark(e.x, e.y))
lb.bind('<B2-Motion>', lambda e: self.scan_dragto(e.x, e.y))
# Dragging outside the window has no effect (diable
# the default listbox behavior, which scrolls):
lb.bind('<B1-Leave>', lambda e: 'break')
# Columns can be resized by dragging them:
l.bind('<Button-1>', self._resize_column)
# Columns can be resized by dragging them. (This binding is
# used if they click on the grid between columns:)
self.bind('<Button-1>', self._resize_column)
# Set up key bindings for the widget:
self.bind('<Up>', lambda e: self.select(delta=-1))
self.bind('<Down>', lambda e: self.select(delta=1))
self.bind('<Prior>', lambda e: self.select(delta=-self._pagesize()))
self.bind('<Next>', lambda e: self.select(delta=self._pagesize()))
# Configuration customizations
self.configure(cnf, **kw)
示例6: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import __init__ [as 别名]
def __init__(self, master):
Frame.__init__(self, master)
self._create_ui()
示例7: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import __init__ [as 别名]
def __init__(self, *args, **kwargs):
Frame.__init__(self, *args, **kwargs)
timer = TkTimer(widget=self, interval=200, active=False)
balloon = Scripting.root_node.balloon
self.__busy_lamp = six.moves.tkinter.Label(self, bg='forestgreen', width=1)
self.__busy_lamp.pack(side=RIGHT, fill='y')
self.__membar = IntVar(0)
self._make_mem_status()
# Transparent Scale {
def on_scale(val):
Scripting.root_node.console.set_transparency(val)
trans_scale = Scale(self, from_=0.2, to=1.0, orient='horizontal', value=1, command=on_scale)
trans_scale.pack(side='right')
balloon.bind_widget(trans_scale, balloonmsg='Set the transparency of the console.')
# } End Transparent Scale
# Topmost Button {
import six.moves.tkinter as tkinter
topmost_button = tkinter.Button(self, text='TOP', relief='groove')
topmost_button.pack(side='right')
def on_click():
tk_root = Scripting.root_node.tk_root
b = bool(tk_root.wm_attributes('-topmost'))
fg = 'black' if b else 'lime green'
topmost_button['fg'] = fg
tk_root.wm_attributes('-topmost', not b)
topmost_button['command'] = on_click
balloon.bind_widget(topmost_button, balloonmsg='Set the console as a topmost window.')
# } End Topmost Button
#{ Window Combo
window_combo = Combobox(self, value=[], takefocus=1, stat='readonly')
def on_selected(event):
text = event.widget.get()
wid = int(text.split(':')[1].strip())
Scripting.root_node.windows[wid].tk_object.deiconify()
window_combo.bind('<<ComboboxSelected>>', on_selected)
window_combo.pack(side='right', fill='y') # deiconify a window
@SimpleObserver
def on_windows_change(node, command):
values = window_combo['values']
if values == '':
values = []
if isinstance(values, tuple):
values = list(values)
node_id = id(node)
if command == 'new':
type_name = node.__class__.__name__
values.append(eval_format('{type_name}: {node_id}'))
elif command == 'del':
for index, value in enumerate(values):
wid = int(value.split(':')[1].strip())
if node_id == wid:
del values[index]
window_combo['values'] = values
if len(values) > 0:
window_combo.current(len(values)-1)
else:
window_combo.set('')
Scripting.root_node.windows.add_observer(on_windows_change)
#} End Window Combo
self.__lock = thread.allocate_lock()
self.__busy = False
get_memory_usage = Scripting.root_node.os.get_memory_usage
@SimpleObserver
def check_busy():
self._set_busy_light()
@SimpleObserver
def check_mem():
self.__membar.set(get_memory_usage())
timer.add_observer(check_busy)
timer.divider(divide_by=10).add_observer(check_mem)
timer.active = True