当前位置: 首页>>代码示例>>Python>>正文


Python Tkinter.Tk方法代码示例

本文整理汇总了Python中Tkinter.Tk方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.Tk方法的具体用法?Python Tkinter.Tk怎么用?Python Tkinter.Tk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tkinter的用法示例。


在下文中一共展示了Tkinter.Tk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_application

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def create_application():
    """
    Create an instance of the MainApplication class defined in this module. 
    Set the GUI to run in its mainloop().
    
    """
    if s.IS_VERBOSE: print "INFO: create_application() called. "
    
    global app
    
    # create the TKinter application
    root = tk.Tk()
    app = MainApplication(master = root)
    app.master.title("PiPark 2014")
    app.mainloop()

# ------------------------------------------------------------------------------
#  Run PiPark
# ------------------------------------------------------------------------------ 
开发者ID:Humpheh,项目名称:PiPark,代码行数:21,代码来源:main.py

示例2: ShowMol

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def ShowMol(mol, size=(300, 300), kekulize=True, wedgeBonds=True, title='RDKit Molecule', **kwargs):
    """ Generates a picture of a molecule and displays it in a Tkinter window
    """
    global tkRoot, tkLabel, tkPI
    try:
        import Tkinter
    except ImportError:
        import tkinter as Tkinter
    try:
        import ImageTk
    except ImportError:
        from PIL import ImageTk

    img = MolToImage(mol, size, kekulize, wedgeBonds, **kwargs)

    if not tkRoot:
        tkRoot = Tkinter.Tk()
        tkRoot.title(title)
        tkPI = ImageTk.PhotoImage(img)
        tkLabel = Tkinter.Label(tkRoot, image=tkPI)
        tkLabel.place(x=0, y=0, width=img.size[0], height=img.size[1])
    else:
        tkPI.paste(img)
    tkRoot.geometry('%dx%d' % (img.size)) 
开发者ID:blackmints,项目名称:3DGCN,代码行数:26,代码来源:__init__.py

示例3: main

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
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() 
开发者ID:univ-of-utah-marriott-library-apple,项目名称:firmware_password_manager,代码行数:24,代码来源:Skeleton_Key.py

示例4: _do_until_timeout

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def _do_until_timeout(self, queue, args):
        rect, color, seconds = args
        if tk._default_root is None:
            Debug.log(3, "Creating new temporary Tkinter root")
            temporary_root = True
            root = tk.Tk()
            root.withdraw()
        else:
            Debug.log(3, "Borrowing existing Tkinter root")
            temporary_root = False
            root = tk._default_root
        image_to_show = self.getBitmapFromRect(*rect)
        app = highlightWindow(root, rect, color, image_to_show, queue)
        app.do_until_timeout(seconds)

    ## Process functions 
开发者ID:glitchassassin,项目名称:lackey,代码行数:18,代码来源:PlatformManagerDarwin.py

示例5: select

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def select(message="", title="Lackey Input", options=None, default=None):
    """ Creates a dropdown selection dialog with the specified message and options

     `default` must be one of the options.

     Returns the selected value. """
    if options is None or len(options) == 0:
        return ""
    if default is None:
        default = options[0]
    if default not in options:
        raise ValueError("<<default>> not in options[]")
    root = tk.Tk()
    input_text = tk.StringVar()
    input_text.set(message)
    PopupList(root, message, title, options, default, input_text)
    root.focus_force()
    root.mainloop()
    return str(input_text.get()) 
开发者ID:glitchassassin,项目名称:lackey,代码行数:21,代码来源:__init__.py

示例6: size_column

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def size_column(self, index, **kw):
        """Queries or sets the size of the column given by
        INDEX.  INDEX may be any non-negative
        integer that gives the position of a given column.
        INDEX can also be the string "default"; in this case, this command
        queries or sets the default size of all columns.
        When no option-value pair is given, this command returns a tuple
        containing the current size setting of the given column.  When
        option-value pairs are given, the corresponding options of the
        size setting of the given column are changed. Options may be one
        of the follwing:
              pad0 pixels
                     Specifies the paddings to the left of a column.
              pad1 pixels
                     Specifies the paddings to the right of a column.
              size val
                     Specifies the width of a column.  Val may be:
                     "auto" -- the width of the column is set to the
                     width of the widest cell in the column;
                     a valid Tk screen distance unit;
                     or a real number following by the word chars
                     (e.g. 3.4chars) that sets the width of the column to the
                     given number of characters."""
        return self.tk.split(self.tk.call(self._w, 'size', 'column', index,
                             *self._options({}, kw))) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:27,代码来源:Tix.py

示例7: size_row

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def size_row(self, index, **kw):
        """Queries or sets the size of the row given by
        INDEX. INDEX may be any non-negative
        integer that gives the position of a given row .
        INDEX can also be the string "default"; in this case, this command
        queries or sets the default size of all rows.
        When no option-value pair is given, this command returns a list con-
        taining the current size setting of the given row . When option-value
        pairs are given, the corresponding options of the size setting of the
        given row are changed. Options may be one of the follwing:
              pad0 pixels
                     Specifies the paddings to the top of a row.
              pad1 pixels
                     Specifies the paddings to the bottom of a row.
              size val
                     Specifies the height of a row.  Val may be:
                     "auto" -- the height of the row is set to the
                     height of the highest cell in the row;
                     a valid Tk screen distance unit;
                     or a real number following by the word chars
                     (e.g. 3.4chars) that sets the height of the row to the
                     given number of characters."""
        return self.tk.split(self.tk.call(
                    self, 'size', 'row', index, *self._options({}, kw))) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:26,代码来源:Tix.py

示例8: test

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def test():
    root = Tkinter.Tk()
    root.geometry("+1+1")
    Tkinter.Button(command=root.quit, text="Quit").pack()
    t1 = Tester(root)
    t1.top.geometry("+1+60")
    t2 = Tester(root)
    t2.top.geometry("+120+60")
    t3 = Tester(root)
    t3.top.geometry("+240+60")
    i1 = Icon("ICON1")
    i2 = Icon("ICON2")
    i3 = Icon("ICON3")
    i1.attach(t1.canvas)
    i2.attach(t2.canvas)
    i3.attach(t3.canvas)
    root.mainloop() 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:19,代码来源:Tkdnd.py

示例9: _setup

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def _setup(self, master, cnf):
        """Internal function. Sets up information about children."""
        if _support_default_root:
            global _default_root
            if not master:
                if not _default_root:
                    _default_root = Tk()
                master = _default_root
        self.master = master
        self.tk = master.tk
        name = None
        if 'name' in cnf:
            name = cnf['name']
            del cnf['name']
        if not name:
            name = repr(id(self))
        self._name = name
        if master._w=='.':
            self._w = '.' + name
        else:
            self._w = master._w + '.' + name
        self.children = {}
        if self._name in self.master.children:
            self.master.children[self._name].destroy()
        self.master.children[self._name] = self 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:27,代码来源:Tkinter.py

示例10: __init__

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def __init__(self, canvas, num, window):
        FigureManagerBase.__init__(self, canvas, num)
        self.window = window
        self.window.withdraw()
        self.set_window_title("Figure %d" % num)
        self.canvas = canvas
        self._num =  num
        _, _, w, h = canvas.figure.bbox.bounds
        w, h = int(w), int(h)
        self.window.minsize(int(w*3/4),int(h*3/4))
        if matplotlib.rcParams['toolbar']=='classic':
            self.toolbar = NavigationToolbar( canvas, self.window )
        elif matplotlib.rcParams['toolbar']=='toolbar2':
            self.toolbar = NavigationToolbar2TkAgg( canvas, self.window )
        else:
            self.toolbar = None
        if self.toolbar is not None:
            self.toolbar.update()
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self._shown = False

        def notify_axes_change(fig):
            'this will be called whenever the current axes is changed'
            if self.toolbar != None: self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:27,代码来源:backend_tkagg.py

示例11: resize

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def resize(self, width, height=None):
        # before 09-12-22, the resize method takes a single *event*
        # parameter. On the other hand, the resize method of other
        # FigureManager class takes *width* and *height* parameter,
        # which is used to change the size of the window. For the
        # Figure.set_size_inches with forward=True work with Tk
        # backend, I changed the function signature but tried to keep
        # it backward compatible. -JJL

        # when a single parameter is given, consider it as a event
        if height is None:
            width = width.width
        else:
            self.canvas._tkcanvas.master.geometry("%dx%d" % (width, height))

        self.toolbar.configure(width=width) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:backend_tkagg.py

示例12: adjust

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def adjust(self, naxes):
        if self._naxes < naxes:
            for i in range(self._naxes, naxes):
                self._axis_var.append(Tk.IntVar())
                self._axis_var[i].set(1)
                self._checkbutton.append( self._mbutton.menu.add_checkbutton(
                    label = "Axis %d" % (i+1),
                    variable=self._axis_var[i],
                    command=self.set_active))
        elif self._naxes > naxes:
            for i in range(self._naxes-1, naxes-1, -1):
                del self._axis_var[i]
                self._mbutton.menu.forget(self._checkbutton[i])
                del self._checkbutton[i]
        self._naxes = naxes
        self.set_active() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:backend_tkagg.py

示例13: simple_window

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def simple_window():
  root = tk.Tk()
  
  image = np.zeros((128, 128, 3), dtype=np.uint8)
  image[32:96, 32:96, 0] = 255
  im = Image.fromarray(image)
  im = ImageTk.PhotoImage(im)
  
  image = np.zeros((128, 128, 3), dtype=np.uint8)
  image[32:96, 32:96, 1] = 255
  im2 = Image.fromarray(image)
  im2 = ImageTk.PhotoImage(im2)
  
  panel = tk.Label(root, image=im)
  
  def left_key(event):
    panel.configure(image=im2)
    panel.image = im2

  def quit(event):
    sys.exit()

  panel.bind('<Left>', left_key)
  panel.bind('<Up>', left_key)
  panel.bind('<Down>', left_key)
  panel.bind('q', quit)
  panel.focus_set()
  panel.pack(side = "bottom", fill = "both", expand = "yes")
  root.mainloop() 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:31,代码来源:script_env_vis.py

示例14: __init__

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def __init__(self, *chart_filenames):
        # This chart is displayed when we don't have a value (eg
        # before any chart is loaded).
        faketok = [''] * 8
        self._emptychart = Chart(faketok)

        # The left & right charts start out empty.
        self._left_name = 'None'
        self._right_name = 'None'
        self._left_chart = self._emptychart
        self._right_chart = self._emptychart
            
        # The charts that have been loaded.
        self._charts = {'None': self._emptychart}

        # The output chart.
        self._out_chart = self._emptychart

        # The most recent operation
        self._operator = None

        # Set up the root window.
        self._root = Tkinter.Tk()
        self._root.title('Chart Comparison')
        self._root.bind('<Control-q>', self.destroy)
        self._root.bind('<Control-x>', self.destroy)

        # Initialize all widgets, etc.
        self._init_menubar(self._root)
        self._init_chartviews(self._root)
        self._init_divider(self._root)
        self._init_buttons(self._root)
        self._init_bindings(self._root)

        # Load any specified charts.
        for filename in chart_filenames:
            self.load_chart(filename) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:39,代码来源:chart.py

示例15: update_preview

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Tk [as 别名]
def update_preview(self, psize):
        # Sanity check that initialization is completed:
        if not self.init_done: return
        # Determine the primary axis of rotation.
        if self.flip_axis.get():
            flip_qq = [0,0,0,1]
        else:
            flip_qq = [0,0,1,0]
        # Calculate the orientation of both lenses.
        front_qq = norm_qq(self.slide_rx.get(),
                           self.slide_ry.get(),
                           self.slide_rz.get())
        align_qq = norm_qq(self.slide_ax.get(),
                           self.slide_ay.get(),
                           self.slide_az.get())
        back_qq = mul_qq(align_qq, mul_qq(flip_qq, front_qq))
        self.panorama.sources[0].lens.center_qq = front_qq
        self.panorama.sources[1].lens.center_qq = back_qq
        # Render the preview.
        # Note: The Tk-Label doesn't maintain a reference to the image object.
        #       To avoid garbage-collection, keep one in this class.
        self.preview_img = ImageTk.PhotoImage(
            self.panorama.render_equirectangular(psize, self.mode.get()))
        # Assign the new icon.
        self.preview_lbl.configure(image=self.preview_img)

    # Find the largest output size that fits within the given bounds and
    # matches the 2:1 aspect ratio of the equirectangular preview. 
开发者ID:ooterness,项目名称:DualFisheye,代码行数:30,代码来源:fisheye.py


注:本文中的Tkinter.Tk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。