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


Python Tk.resizable方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
class CreateRootDimension:
    def __init__(self):
        self.dimx = 0
        self.dimy = 0
        self.popup_dim = Tk()
        self.popup_dim.title("Dimensions")
        center(self.popup_dim, 200, 120)
        self.popup_dim.resizable(False, False)
        canvas = Canvas(self.popup_dim, width=200, height=120, bg="#eff")
        dimx = Entry(self.popup_dim, width=5, relief="raised")
        dimy = Entry(self.popup_dim, width=5, relief="raised")
        ok = Button(self.popup_dim, text="OK",
                    command=lambda: self.setrootdimension(dimx.get(), dimy.get()),
                    width=1, font="../font/myfont 6 bold", fg="#eee")
        canvas.create_window(100, 30, window=dimx)
        canvas.create_text(65, 30, text="X=")
        canvas.create_window(100, 60, window=dimy)
        canvas.create_text(65, 60, text="Y=")
        canvas.create_window(100, 85, window=ok)
        canvas.pack()

    def setrootdimension(self, dimx, dimy):
        try:
            self.dimx = int(dimx)
            self.dimy = int(dimy)
            self.popup_dim.destroy()
        except ValueError:
            showerror("Erreur", "Veuillez saisir des entiers")

    def getrootdimension(self):
        return self.dimx, self.dimy
开发者ID:mourma10,项目名称:ProjetDIC1_OO,代码行数:33,代码来源:root.py

示例2: init_master

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
def init_master():
    """初始化主窗口"""
    global master
    master = Tk()
    master.title(u'花田')
    master.geometry(u'630x530')
    master.resizable(width=False, height=False)
开发者ID:WiseDoge,项目名称:huatian-funny,代码行数:9,代码来源:mark.py

示例3: Wall

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
class Wall(object):
    MIN_RED = MIN_GREEN = MIN_BLUE = 0x0
    MAX_RED = MAX_GREEN = MAX_BLUE = 0xFF

    PIXEL_WIDTH = 96

    def __init__(self, width, height):
        self.width = width
        self.height = height
        self._tk_init()
        self.pixels = [(0, 0, 0) for i in range(self.width * self.height)]

    def _tk_init(self):
        self.root = Tk()
        self.root.title("ColorWall %d x %d" % (self.width, self.height))
        self.root.resizable(0, 0)
        self.frame = Frame(self.root, bd=5, relief=SUNKEN)
        self.frame.pack()

        self.canvas = Canvas(self.frame,
                             width=self.PIXEL_WIDTH * self.width,
                             height=self.PIXEL_WIDTH * self.height,
                             bd=0, highlightthickness=0)
        self.canvas.pack()
        self.root.update()

    def set_pixel(self, x, y, hsv):
        self.pixels[self.width * y + x] = hsv

    def get_pixel(self, x, y):
        return self.pixels[self.width * y + x]

    def draw(self):
        self.canvas.delete(ALL)
        for x in range(len(self.pixels)):
            x_0 = (x % self.width) * self.PIXEL_WIDTH
            y_0 = (x / self.width) * self.PIXEL_WIDTH
            x_1 = x_0 + self.PIXEL_WIDTH
            y_1 = y_0 + self.PIXEL_WIDTH
            hue = "#%02x%02x%02x" % self._get_rgb(self.pixels[x])
            self.canvas.create_rectangle(x_0, y_0, x_1, y_1, fill=hue)
        self.canvas.update()

    def clear(self):
        for i in range(self.width * self.height):
            self.pixels[i] = (0, 0, 0)

    def _hsv_to_rgb(self, hsv):
        rgb = colorsys.hsv_to_rgb(*hsv)
        red = self.MAX_RED * rgb[0]
        green = self.MAX_GREEN * rgb[1]
        blue = self.MAX_BLUE * rgb[2]
        return (red, green, blue)

    def _get_rgb(self, hsv):
        red, green, blue = self._hsv_to_rgb(hsv)
        red = int(float(red) / (self.MAX_RED - self.MIN_RED) * 0xFF)
        green = int(float(green) / (self.MAX_GREEN - self.MIN_GREEN) * 0xFF)
        blue = int(float(blue) / (self.MAX_BLUE - self.MIN_BLUE) * 0xFF)
        return (red, green, blue)
开发者ID:Ray-SunR,项目名称:colorwall,代码行数:62,代码来源:wall.py

示例4: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
  class Dashboard:
    """
    Dashboard class created, is launched in a new thread.
    """
    def __init__(self, labels, nb_digits, queue):
      self.root = Tk()
      self.root.title('Dashboard')
      self.root.resizable(width=False, height=False)
      self.first_column = labels
      self.nb_digits = nb_digits
      self.c2 = []
      self.queue = queue
      # Creating the first and second column. Second column will be updated.
      for row_index, first_column in enumerate(self.first_column):
        Label(self.root, text=first_column, borderwidth=15,
              font=("Courier bold", 48)).grid(row=row_index, column=0)
        self.c2.append(
          Label(self.root, text='', borderwidth=15, font=("Courier bold", 48)))
        self.c2[row_index].grid(row=row_index, column=1)
      self.i = 0
      while True:
        self.update()

    def update(self):
      """
      Method to update the output window.
      """
      values = self.queue.get()
      for row, text in enumerate(values):
        self.c2[row].configure(text='%.{}f'.format(self.nb_digits) % text)
      self.root.update()
开发者ID:LaboratoireMecaniqueLille,项目名称:crappy,代码行数:33,代码来源:dashboard.py

示例5: TronCanvas

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
class TronCanvas(object):
    """
    Tron canvas class, contains the fields related to drawing the game. Canvas
    is used to draw the Players on the screen. The drawing is done by Tk.

    Attributes:

    - Root -- The root Tk instance
    - Canvas -- The TkCanvas
    - Bike width -- Width of the bike in pixels
    - Rows -- Number of cells in each row of the board.
      The Bike width x Rows + 2 x MARGIN gives the size in pixels of the
      canvas.

    MARGIN
      The margin of the canvas

    DELAY
      Delay time between redrawing the canvas

    GUI_DISPLAY_AFTER_COLLISION
      Time in seconds GUI is displayed after a collision. Default is 2 seconds
    """

    # Margin of canvas in pixels
    MARGIN = 5
    # Delay between updates in milliseconds
    DELAY = 150
    # Time GUI is displayed after a collision
    GUI_DISPLAY_AFTER_COLLISION = 2

    def __init__(self, rows, bike_width):
        """
        Constructor

        :param rows: number of rows on the grid
        :type rows: int
        :param bike_width: width of bike when drawing
        :type bike_width: int
        """
        # Create Tk instance
        self.root = Tk()
        # Set window to be resizable
        self.root.resizable(width=0, height=0)
        # Canvas to draw on
        canvas_width = 2 * TronCanvas.MARGIN + rows * bike_width
        canvas_height = canvas_width
        # Create a Tk Canvas instance
        self.tk_canvas = Canvas(self.root, width=canvas_width,
                                height=canvas_height)
        # Geometry manager organizes widgets in blocks before placing
        # them in the parent widget
        self.tk_canvas.pack()
        # Set bike width
        self.bike_width = bike_width
        # Set bike height
        self.bike_height = bike_width
        # Set number of rows
        self.rows = rows
开发者ID:hembergerik,项目名称:EC-Stable,代码行数:61,代码来源:ai_tron_non_adversarial.py

示例6: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
def main():
    root = Tk()
    root.title("PicasaWeb Uploader v%s" % __version__)
    root.resizable(False, False)
    root.geometry('400x500+300+100')

    app = GUI(root)
    root.mainloop()
开发者ID:Libitum,项目名称:SimplePicasaWebUploader,代码行数:10,代码来源:spwu_gui.py

示例7: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
class GameGUI:

  def __init__(self):
    self.app = Tk()
    self.app.title('Tic Tac Toe A.I')
    self.app.resizable(width=False, height=False)
    self.board = GameAI()
    self.font = Font(family = "Arial", size = 28)
    self.buttons = {}
    for x,y in self.board.fields:
     handler = lambda x = x, y = y: self.move(x,y)
     button = Button(self.app, command = handler, font = self.font, width = 2,height = 1)
     button.grid(row = y, column = x)
     self.buttons[x,y] = button
    handler = lambda: self.reset()
    button = Button(self.app,text = 'reset',command = handler)
    button.grid(row = self.board.dim+1, column = 0, columnspan = self.board.dim,sticky="WE")
    self.quit = Button(self.app,text = 'quit', command = self.app.quit)
    self.quit.grid(row = self.board.dim+2, column = 0, columnspan = self.board.dim,sticky="WE")
    print "Dear Player, to mave a move click on any button and wait for A.I..."

  def reset(self):
    self.board = GameAI()
    self.update()

  def move(self,x,y):
    self.app.config(cursor = "watch")
    self.app.update()
    self.board = self.board.move(x,y)
    self.update()
    move = self.board.best()
    if move:
     self.board = self.board.move(*move)
     self.update()
    self.app.config(cursor = "")

  def update(self):
   for (x,y) in self.board.fields:
     text = self.board.fields[x,y]
     self.buttons[x,y]['text'] = text
     self.buttons[x,y]['disabledforeground'] = 'black'
     if text == self.board.empty:
       self.buttons[x,y]['state'] = 'normal'
     else:
       self.buttons[x,y]['state'] = 'disabled'
     winning = self.board.won()
     if winning:
      for x,y in winning:
       self.buttons[x,y]['disabledforeground'] = 'red'
      for x,y in self.buttons:
       self.buttons[x,y]['state']= 'disabled'
      for (x,y) in self.board.fields:
       self.buttons[x,y].update()

  def mainloop(self):
    self.app.mainloop()
开发者ID:DachiCoding,项目名称:tictactoe,代码行数:58,代码来源:tictactoe.py

示例8: main_root

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
def main_root():
    iam_root = Tk()
    iam_root.title("Projet Python DIC1")
    w_ = iam_root.winfo_screenwidth()
    h = iam_root.winfo_screenheight()
    x = w_ / 2 - dimx_ / 2
    y = h / 2 - dimy_ / 2
    iam_root.geometry("%dx%d+%d+%d" % ((dimx_, dimy_) + (x, y)))
    iam_root.resizable(False, False)
    return iam_root
开发者ID:mourma10,项目名称:Projet_Algebre_DIC1,代码行数:12,代码来源:getroot.py

示例9: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
class GUI:

  def __init__(self):
    self.app = Tk()
    self.app.title('TicTacToe')
    self.app.resizable(width=False, height=False)
    self.board = Board()
    self.font = Font(family="Helvetica", size=32)
    self.buttons = {}
    for x,y in self.board.fields:
      handler = lambda x=x,y=y: self.move(x,y)
      button = Button(self.app, command=handler, font=self.font, width=2, height=1)
      button.grid(row=y, column=x)
      self.buttons[x,y] = button
    handler = lambda: self.reset()
    button = Button(self.app, text='reset', command=handler)
    button.grid(row=self.board.size+1, column=0, columnspan=self.board.size, sticky="WE")
    self.update()

  def reset(self):
    self.board = Board()
    self.update()

  def move(self,x,y):
    self.app.config(cursor="watch")
    self.app.update()
    self.board = self.board.move(x,y)
    self.update()
    move = self.board.best()
    if move:
      self.board = self.board.move(*move)
      self.update()
    self.app.config(cursor="")

  def update(self):
    for (x,y) in self.board.fields:
      text = self.board.fields[x,y]
      self.buttons[x,y]['text'] = text
      self.buttons[x,y]['disabledforeground'] = 'black'
      if text==self.board.empty:
        self.buttons[x,y]['state'] = 'normal'
      else:
        self.buttons[x,y]['state'] = 'disabled'
    winning = self.board.won()
    if winning:
      for x,y in winning:
        self.buttons[x,y]['disabledforeground'] = 'red'
      for x,y in self.buttons:
        self.buttons[x,y]['state'] = 'disabled'
    for (x,y) in self.board.fields:
      self.buttons[x,y].update()

  def mainloop(self):
    self.app.mainloop()
开发者ID:c0ns0le,项目名称:Pythonista,代码行数:56,代码来源:ttt.py

示例10: root_operation

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
def root_operation(n, title):
    root_op = Tk()
    canvas = Canvas(root_op, width=200 * n - 100, height=100 * n - 50, bg="#cdd")
    w_ = root_op.winfo_screenwidth()
    h = root_op.winfo_screenheight()
    x = w_ / 2 - (200 * n - 100) / 2
    y = h / 2 - (100 * n - 50) / 2
    root_op.title(title)
    root_op.geometry("%dx%d+%d+%d" % ((200 * n - 100, 100 * n - 50) + (x, y)))
    root_op.resizable(False, False)
    return root_op, canvas
开发者ID:mourma10,项目名称:Projet_Algebre_DIC1,代码行数:13,代码来源:getroot.py

示例11: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
def main():
  
    root = Tk()
    #setting the window height and width
    root.geometry("235x200+100+100")
    #setting background color
    root.configure(background='grey')
    #setting window title
    root.title("Calculator")
    root.resizable(0,0)
    textframe = calculator(root)
    root.mainloop()  
开发者ID:ashifkalladi,项目名称:Calculator-application-using-python,代码行数:14,代码来源:calculator.py

示例12: start_gui

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
def start_gui():
    (width, height) = (640, 480)
    root = Tk()
    canvas = Canvas(root, width=width, height=height)
    canvas.pack()
    root.resizable(width=FALSE, height=FALSE)
    class Struct(): pass
    canvas.data = Struct()
    canvas.data.width = width
    canvas.data.height= height
    canvas.data.root = root
    init(canvas)
    redrawAll(canvas)
    timerFired(canvas)
    canvas.data.root.mainloop()
开发者ID:bperez77,项目名称:FPGA-data-logger,代码行数:17,代码来源:control_GUI.py

示例13: __init__

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
class GUI:
    def __init__(self):
        self.app = Tk()
        self.app.title('War Game')
        self.app.resizable(width=False, height=False)
        self.font = Font(family="Helvetica", size=32)
        self.buttons = {}
        self.board = Board('./boards/Smolensk.txt')
        self.size = SIZE

        for y in xrange(1, self.size + 1):
            for x in xrange(1, self.size + 1):
                handler = lambda x=x, y=y: self.move(x, y)
                button = Button(self.app, command=handler, font=self.font, width=3, height=1, text=self.board.values[y, x], background='gray')
                button.grid(row=y, column=x)
                self.buttons[x, y] = button

        handler = lambda: self.auto_move()
        button = Button(self.app, text='Start AI', command=handler)
        button.grid(row=self.size + 1, column=1, columnspan=self.size, sticky="WE")

    def auto_move(self):
        while self.board.nodes_left > 0:
            if self.board.player == 1:
                cost, (y, x) = self.board.root_negalphabeta()
            else:
                cost, (y, x) = self.board.root_negalphabeta()

            print 'Player: {} Heuristic {}'.format(self.board.player, cost)
            self.move(x, y)
            print 'Score: {}'.format(self.board.score)

    def move(self, x, y):
        self.app.config(cursor="watch")
        self.app.update()
        self.board.move(x, y)
        self.update(x, y)
        self.app.config(cursor="")

    def update(self, x, y):
        self.buttons[x, y]['state'] = 'disabled'
        for y in xrange(1, self.size + 1):
            for x in xrange(1, self.size + 1):
                self.buttons[x, y]['background'] = COLORS[self.board.colors[y, x]]
                self.buttons[x, y].update()

    def mainloop(self):
        self.app.mainloop()
开发者ID:aqiu384,项目名称:cs440,代码行数:50,代码来源:tic2.py

示例14: main

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
def main():
    root = Tk()
    root.resizable(0, 0)

    frame_t = Frame(root)
    frame_t.pack(fill=BOTH, expand=False)

    table = ZenTable(frame_t, TBL_WIDTH, TBL_HEIGHT)

    ball = Ball(BALL_RADIUS)
    bs = BoustrophedonSolver(table, ball)
    cs = ContourSolver(table, ball, bs.is_rockpoint)
    bg = LinearBackground(table, ball)

    def solve_boustrophedon():
        print "--------------" #
        #table.debug()
        bs.solve()
        #bs.animate_path(15)
        bs.show_covered_points()
        bs.show_visited_points()
        cs.solve(bs.get_visited_list(), 3)
        cs.draw_contours()
        bg.solve(bs.get_visited_list(), dict([(p, v is not None) for (p, v) in cs.proximity_map.iteritems()]))
        bg.draw()


    def on_reset():
        bs.stop_animating()
        table.resetSimulation()


    def draw_ripples():
        rip = SandRipple(TBL_WIDTH, TBL_HEIGHT)
        for i in range(200):
            print "Iteration #", i
            rip.iterate(20.0, 0.5, 0.0, 0.0, 0.1, 0.8, 0, 1)

            for x, col in enumerate(rip.normalize(255)):
                for y, val in enumerate(col):
                    myColor = "#%0.2x%0.2x%0.2x" % ((val,) * 3)
                    table.draw_point(x, y, myColor)
            table.drawing_area.update_idletasks()

            
    buttons = ButtonBar(root, solve_boustrophedon, on_reset) # do the explorer
    #buttons = ButtonBar(root, draw_ripples, table.resetSimulation)        # do the sand ripple sim
    root.mainloop()
开发者ID:ifreecarve,项目名称:ZenGardenTable,代码行数:50,代码来源:table_main.py

示例15: run

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import resizable [as 别名]
def run(): # Main function that triggers the rest of the game
    root = Tk() # Initializes a new root
    root.resizable(width = FALSE, height = FALSE) # The canvas is not resizable
    root.title("Boggle - Aayush Tekriwal - (15-112 Term Project)") # Title
    (width, height) = (1000,600) # Width and height of 
    canvas = Canvas(root, width = width, height = height)
    canvas.pack()
    root.canvas = canvas.canvas = canvas
    class Struct: pass
    canvas.data = Struct() # Struct stores all data for global access
    canvas.data.width = width
    canvas.data.height = height
    initGame(root, canvas) 
    #root.bind("<Button-1>", printCoords) # Unhash to help modify graphics
    root.bind("<space >", lambda event: getWord(canvas, event))
    root.bind("<Return>", lambda event: getWord(canvas, event))
    root.mainloop()
开发者ID:aayushtekriwal,项目名称:BoggleBash_15112_Term-Project_Aayush-Tekriwal,代码行数:19,代码来源:BoggleBash.py


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