0
我爲我正在設計的設計創建了一個GUI,並且畫布在新窗口中彈出。我試圖讓它出現在按鈕下方。我不能讓畫布工作,我想如何去
__author__ = 'Isaac Alderton'
__authorEmail__ = '[email protected]'
from Tkinter import *
class Application(Frame):
""" My smart board application"""
def __init__(self, master):
Frame.__init__(self, master)
self.grid()
self.create_widgets()
def create_widgets(self):
#Button1
#buttons ment to span across the width of the page
#needs linking to google calander
self.button1 = Button(self, text = " Calandar ")
self.button1.grid(row=1,column = 1)
#button2
self.button2 = Button(self, text = " weather ")
self.button2.grid(row=1,column = 2)
#button3
#defult home menu in the future user sets a new home
self.button3 = Button(self, text = " Whiteboard ")
self.button3.grid(row=1,column = 3)
#button4
self.button4 = Button(self, text = " Internet ")
self.button4.grid(row=1,column = 4)
#button5
self.button5 = Button(self, text = " Settings ")
self.button5.grid(row=1,column = 5)
#def settings():
#pop up window where the settings options have wifi screen brightness sleep options
#and also account settings
#One day also ui changes so color themes etc
#Canvas
#canvas ment to be part of whiteboard screen not a "pop-up"
#canvas is ment to fill the whole page
def xy(event):
global lastx, lasty
lastx, lasty = event.x, event.y
def addLine(event):
global lastx, lasty
canvas.create_line((lastx, lasty, event.x, event.y))
lastx, lasty = event.x, event.y
root = Tk()
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
canvas = Canvas(root)
canvas.grid(column=5, row=4,)
canvas.bind("<Button-1>", xy)
canvas.bind("<B1-Motion>", addLine)
#endof canvas
root = Tk()
root.title("Smartboard")
#Geometry is ment to fit device????
root.geometry("530x500")
app = Application(root)
root.mainloop()
# Copyright {2015} {Isaac Alderton}
現在我有它的問題,不會聽行或colums我需要在頂部王氏文本框是他們之前是如何在那裏畫布出現在同一窗口中:/如果你運行「破碎」的代碼,它顯示你的佈局應該如何......當我改變畫布到任何東西,但colum = 0它不工作..... –
@IsaacAlderton完成。 – matsjoyce
你先生很棒:) –