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


Python Tk.resizable方法代码示例

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


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

示例1: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import resizable [as 别名]
def main():
    '''runs the program'''
    square_width = 64
    num_cols = 7
    num_rows = 6
    canvas_width = (num_cols+1)*square_width
    canvas_height = (num_rows+1)*square_width

    window = Tk()
    window.configure(background='black')
    window.title("DynaBLASTER")
    window.resizable(0,0) #removes maximize option
    #window.iconbitmap('icon.ico')
    #window.tk.call('tk', 'scaling', 20.0)

    canvas = Canvas(window, width=canvas_width, highlightthickness=0,
                    height=canvas_height, background='#717171')
    canvas.grid(row=1,column=0, columnspan=5)

    graphics = Graphics(canvas, num_rows, num_cols, square_width, window)
    board = Board(canvas, square_width, num_rows, num_cols,
                  canvas_width, canvas_height)
    col=0
    row=0
    player1 = Player(canvas, board, square_width, graphics, col, row)
    col = graphics.cols - 3
    row = graphics.rows - 3
    player2 = Player(canvas, board, square_width, graphics, col, row)

    # Import settings from bindings file
    bindings_file = open('bindings.json')
    p1_bindings, p2_bindings, gen_bindings = json.load(bindings_file)

    window.bind(key_release_of(p1_bindings["Up"]), lambda event:player1.key_release('Up'))
    window.bind(key_release_of(p1_bindings["Down"]), lambda event:player1.key_release('Down'))
    window.bind(key_release_of(p1_bindings["Left"]), lambda event:player1.key_release('Left'))
    window.bind(key_release_of(p1_bindings["Right"]), lambda event:player1.key_release('Right'))
    window.bind(p1_bindings["Up"], lambda event:player1.key_press('Up'))
    window.bind(p1_bindings["Down"],lambda event:player1.key_press('Down'))
    window.bind(p1_bindings["Left"], lambda event:player1.key_press('Left'))
    window.bind(p1_bindings["Right"], lambda event:player1.key_press('Right'))
    window.bind(p1_bindings["Bomb"], player1.place_bomb)

    window.bind(key_release_of(p2_bindings["Up"]), lambda event:player2.key_release('Up'))
    window.bind(key_release_of(p2_bindings["Down"]), lambda event:player2.key_release('Down'))
    window.bind(key_release_of(p2_bindings["Left"]), lambda event:player2.key_release('Left'))
    window.bind(key_release_of(p2_bindings["Right"]), lambda event:player2.key_release('Right'))
    window.bind(p2_bindings["Up"], lambda event:player2.key_press('Up'))
    window.bind(p2_bindings["Down"], lambda event:player2.key_press('Down'))
    window.bind(p2_bindings["Left"], lambda event:player2.key_press('Left'))
    window.bind(p2_bindings["Right"], lambda event:player2.key_press('Right'))
    window.bind(p2_bindings["Bomb"], player2.place_bomb)

    window.bind(gen_bindings["Pause"], lambda event:pause_game(player1, player2, graphics))

    window.mainloop()
开发者ID:abel465,项目名称:DynaBLASTER,代码行数:58,代码来源:DynaBLASTER.py

示例2: draw_gui

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import resizable [as 别名]
 def draw_gui(self):
     main = Tk()
     main.title('KindleButler ' + __version__)
     main.resizable(0, 0)
     main.wm_attributes('-toolwindow', 1)
     x = (main.winfo_screenwidth() - main.winfo_reqwidth()) / 2
     y = (main.winfo_screenheight() - main.winfo_reqheight()) / 2
     main.geometry('+%d+%d' % (x, y))
     progressbar = ttk.Progressbar(orient='horizontal', length=200, mode='determinate')
     progressbar.grid(row=0)
     style = ttk.Style()
     style.configure('BW.TLabel', foreground='red')
     label = ttk.Label(style='BW.TLabel')
     return main, progressbar, label
开发者ID:knigophil,项目名称:KindleWisper,代码行数:16,代码来源:kindlewisper.py

示例3: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import resizable [as 别名]
def main():
    root = Tk()
    root.title("Paddle Game")
    root.resizable(0, 0)
    root.wm_attributes("-topmost", 1)
    canvas = Canvas(root, width=500, height=400, bd=0, highlightthickness=0)
    canvas.pack()
    root.update()

    paddle = Paddle(canvas, "blue")
    ball = Ball(canvas, paddle, "red")

    while True:
        if not ball.hit_bottom:
            ball.draw()
            paddle.draw()
        root.update_idletasks()
        root.update()
        time.sleep(0.01)
开发者ID:yasusii,项目名称:sandbox,代码行数:21,代码来源:bouncer.py

示例4: 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 = 50

    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:rkedge,项目名称:ColorWall,代码行数:62,代码来源:wall.py

示例5: __init__

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import resizable [as 别名]
    def __init__(self, num_rows, num_cols, best_possible):
        self.rows = num_rows
        self.cols = num_cols
        self.expectedBest = best_possible
        # create the root and the canvas
        root = Tk()
        # local function to bind/unbind events
        self.bind = root.bind
        self.unbind = root.unbind
        # local function to change title
        self.updateTitle = root.title
        # local function to change cursor
        self.updateCursor = lambda x: root.config(cursor=x)
        # local function to start game
        self.start = root.mainloop
        # get screen width and height
        ws = root.winfo_screenwidth()
        hs = root.winfo_screenheight()

        # fix scaling for higher resolutions
        if max(self.canvasWidth / ws, self.canvasHeight / hs) < 0.45:
            self.scale = 2

        self.canvas = Canvas(root, width=self.canvasWidth, height=self.canvasHeight)
        self.canvas.pack()
        # calculate position x, y
        x = (ws - self.canvasWidth) // 2
        y = (hs - self.canvasHeight) // 2
        root.geometry('%dx%d+%d+%d' % (self.canvasWidth, self.canvasHeight, x, y))
        root.resizable(width=0, height=0)
        self.init()
        # set up keypress events
        root.bind("<Key>", self.keyPressed)
开发者ID:wil93,项目名称:pentomino-cover-game,代码行数:35,代码来源:game.py

示例6: main

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

    root = Tk()
    root.geometry("927x550+50+50")
    root.resizable(width=False, height=False)
    app = Example(root)
    root.mainloop()
开发者ID:Ealdor,项目名称:EQGuildViewer,代码行数:9,代码来源:GuildViewer.py

示例7: independentScreen

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import resizable [as 别名]
class independentScreen():
	screenDict = {}
	def __init__(self):
		if self._available():
			self.quit()
			return False

		self.root = Tk()
		self.root.protocol("WM_DELETE_WINDOW", self.quit)
		self.root.resizable(0, 0)
		self.root.focus_force()
		independentScreen.screenDict[self._name()] = self

	def _name(self):
		return self.__class__.__name__

	def _available(self):
		return self._name() in independentScreen.screenDict and isinstance(independentScreen.screenDict[self._name()], type(self))

	def quit(self):
		try:
			independentScreen.screenDict[self._name()].root.destroy()
			del independentScreen.screenDict[self._name()]
		except:
			pass
开发者ID:cr0sh,项目名称:NaOH,代码行数:27,代码来源:independentScreen.py

示例8: main

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

    root = Tk()
    root.geometry("1100x450+300+300")
    root.resizable(width=False,height=False)
    app = Window(root)
    root.mainloop()
开发者ID:arran-dengate,项目名称:light-pollution,代码行数:9,代码来源:controller.py

示例9: main

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

    root = Tk()
    root.geometry("320x350+300+300")
    root.resizable(0,0)
    app = MainWindow(root)
    root.mainloop()
开发者ID:sopoforic,项目名称:cgrr-mariospicross,代码行数:9,代码来源:marios_picross_puzzle_editor_gui.py

示例10: CameraView

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import resizable [as 别名]
class CameraView(View):
    def __init__(self, params):
        super(CameraView, self).__init__(params)

        self._multiplier = int(params["multiplier"]) if "multiplier" in params else 1
        self._multiplier = max(self._multiplier, 1)

        self._tk = Tk()
        self._canvas = Canvas(self._tk, width=80 * self._multiplier, height=60 * self._multiplier)

        self._tk.title("Camera view")
        self._tk.resizable(width=False, height=False)
        self._canvas.pack(side=tkinter.LEFT, fill=tkinter.BOTH, expand=True)

        self._tk.protocol("WM_DELETE_WINDOW", self.on_press_close)

        self._base_dir = "camera_" + str(int(time.time() * 1000))
        os.makedirs(self._base_dir)

    def run(self):
        super(CameraView, self).run()
        self._tk.mainloop()

    def on_new_input(self):
        try:
            hex_str = self.get_input()
            img = self._get_image(hex_str)
        except Exception as e:
            logging.debug(str(e))
            return
        if img is None:
            return

        bmp = ImageTk.BitmapImage(image=img, foreground="white", background="black")
        self._canvas.create_image(0, 0, image=bmp, anchor=tkinter.NW)
        self._tk_image = bmp

        img.save(self._base_dir + "/" + str(int(time.time() * 1000)) + ".png")

    def on_dismiss(self):
        self._tk.after_idle(self.on_press_close)

    def on_press_close(self):
        self._tk.destroy()
        self.join_io_thread()

    def _get_image(self, hex_str) -> Image:
        try:
            hex_data = binascii.unhexlify(hex_str)
            # Invert data from MCU
            hex_data = bytes([~h & 0xFF for h in hex_data])
        except TypeError as e:
            logging.debug(str(e))
            return

        img = Image.frombytes(mode="1", size=(80, 60), data=hex_data)
        img = img.resize((80 * self._multiplier, 60 * self._multiplier))
        return img
开发者ID:hkust-smartcar,项目名称:sc-studio,代码行数:60,代码来源:camera_view.py

示例11: __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,代码来源:ttt3.py

示例12: __init__

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import resizable [as 别名]
	def __init__(self, message, title='알림', callback=None, grab_focus = False):
		tk=Tk()
		tk.resizable(0, 0)
		self.frame = Frame(tk, border=7)
		self.frame.pack(expand='true')
		self.frame.master.title(title)
		Label(self.frame, text=message).pack(side='top', expand='true')
		self.callback=callback
		Button(self.frame, text="확인", command=self.onPress).pack(expand='true')
		tk.focus_force()
		if grab_focus:
			tk.grab_set_global()
开发者ID:cr0sh,项目名称:NaOH,代码行数:14,代码来源:msgbox.py

示例13: main

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

	window = Tk()
	window.title('A. Dobrunov')
	window.resizable(width=False, height=False)
	color1 = 'lightgreen'
	frame = Frame(window, bg=color1)
	frame.pack()
	Label(frame, text="Laborarbeit № 1 , Variante № 1\n", justify=CENTER, font=("Helvetica", 12), bd=10, bg=color1).pack()
	Label(frame, text="\n Punkte:", justify=CENTER, font=("Helvetica", 12), bd=0, bg=color1).pack()
	e = Entry(frame, bd = 2)
	e.pack()
	Label(frame, text='\n', bg=color1).pack()
	button = Button(frame, text="Ausführen", font=("Helvetica", 12), bg='white', command=lambda: Paint(int(e.get())))
	button.pack()
	window.mainloop()
开发者ID:MentalModel,项目名称:countExp,代码行数:18,代码来源:mentalmodel.py

示例14: Frame1

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import resizable [as 别名]
def Frame1():
    master = Tk()
    master.resizable(width=0, height=0)
    master.geometry("800x600")
    master.config(bg="gold")

    label_huidig_station = Label(master, text = "{}".format(bestemming_input))
    label_huidig_station.place(x=100, y=100)
    label_Tijd0 = Label(master, text = "{}".format(vertrektijd_list[0]))
    label_Tijd0.place(x = 200, y= 150 )
    label_Eindbestemming0 = Label(master, text = "{}".format(eindbestemming_list[0]))
    label_Eindbestemming0.place(x = 300, y = 150)
    label_Spoor0 = Label(master, text = "{}".format(spoor_list[0]))
    label_Spoor0.place(x = 550, y = 150)
    label_Typetrein0 = Label(master, text = "{}".format(treinsoort_list[0]))
    label_Typetrein0.place(x= 320, y = 200)

    label_Tijd1 = Label(master, text = "{}".format(vertrektijd_list[1]))
    label_Tijd1.place(x = 200, y= 250 )
    label_Eindbestemming1 = Label(master, text = "{}".format(eindbestemming_list[1]))
    label_Eindbestemming1.place(x = 300, y = 250)
    label_Spoor1 = Label(master, text = "{}".format(spoor_list[1]))
    label_Spoor1.place(x = 550, y = 250)
    label_Typetrein1 = Label(master, text = "{}".format(treinsoort_list[1]))
    label_Typetrein1.place(x= 320, y = 300)

    label_Tijd2 = Label(master, text = "{}".format(vertrektijd_list[2]))
    label_Tijd2.place(x = 200, y= 350 )
    label_Eindbestemming2 = Label(master, text = "{}".format(eindbestemming_list[2]))
    label_Eindbestemming2.place(x = 300, y = 350)
    label_Spoor2 = Label(master, text = "{}".format(spoor_list[2]))
    label_Spoor2.place(x = 550, y = 350)
    label_Typetrein2 = Label(master, text = "{}".format(treinsoort_list[2]))
    label_Typetrein2.place(x= 320, y = 400)

    label_Tijd3 = Label(master, text = "{}".format(vertrektijd_list[3]))
    label_Tijd3.place(x = 200, y= 450 )
    label_Eindbestemming3 = Label(master, text = "{}".format(eindbestemming_list[3]))
    label_Eindbestemming3.place(x = 300, y = 450)
    label_Spoor3 = Label(master, text = "{}".format(spoor_list[3]))
    label_Spoor3.place(x = 550, y = 450)
    label_Typetrein3 = Label(master, text = "{}".format(treinsoort_list[3]))
    label_Typetrein3.place(x= 320, y = 500)

    master.mainloop()
开发者ID:MrSloppy,项目名称:A1_groepS4_miniproject,代码行数:47,代码来源:laatstehoop2.py

示例15: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import resizable [as 别名]
def main():
	root = Tk()
	root.title("Utagumo")

	root.resizable(width=FALSE, height=FALSE)
	ws = root.winfo_screenwidth()
	hs = root.winfo_screenheight()
	root.geometry('+%d+%d' % (ws/2, hs/2))

	app = UtaGUI(root)
	def shutdown():
		app.cleanup()
		root.destroy()
	root.protocol("WM_DELETE_WINDOW", shutdown)

	logging.info("Running")
	root.mainloop()
	logging.info("Dying")
开发者ID:klaxa,项目名称:utagumo-client,代码行数:20,代码来源:TkClient.py


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