求助,关于Python3.4的Tk组件做GUI的问题
1个回答
2017-04-02 · 知道合伙人互联网行家
关注
展开全部
# -*- coding: utf-8 -*-
# please input your code here.
from random import randint
import tkinter
from tkinter import *
from tkinter import messagebox
def main():
root = Tk()# 创建 GUI 主程序
calculator = Label()# 创建主窗口
calculator.pack(fill=BOTH, expand = 1)
addWidgets(calculator) # 调用函数,向窗口上添加功能按钮,以输入数字和运算符
root.title('Calculator')
root.wm_resizable(width = False, height = False) # 禁用窗口缩放
root.mainloop()
def addWidgets(frame):
n1=randint(1,13)
n2=randint(1,13)
n3=randint(1,13)
n4=randint(1,13)
expression = Text(frame, height = 2, width = 28) # 创建表达式输入窗口
number_1 = Button(frame, text=n1, width = 5,command = lambda: input_char(n1, expression))
number_2 = Button(frame, text=n2, width = 5,command = lambda: input_char(n2, expression))
number_3 = Button(frame, text=n3, width = 5,command = lambda: input_char(n3, expression))
number_4 = Button(frame, text=n4, width = 5,command = lambda: input_char(n4, expression))
# please input your code here.
from random import randint
import tkinter
from tkinter import *
from tkinter import messagebox
def main():
root = Tk()# 创建 GUI 主程序
calculator = Label()# 创建主窗口
calculator.pack(fill=BOTH, expand = 1)
addWidgets(calculator) # 调用函数,向窗口上添加功能按钮,以输入数字和运算符
root.title('Calculator')
root.wm_resizable(width = False, height = False) # 禁用窗口缩放
root.mainloop()
def addWidgets(frame):
n1=randint(1,13)
n2=randint(1,13)
n3=randint(1,13)
n4=randint(1,13)
expression = Text(frame, height = 2, width = 28) # 创建表达式输入窗口
number_1 = Button(frame, text=n1, width = 5,command = lambda: input_char(n1, expression))
number_2 = Button(frame, text=n2, width = 5,command = lambda: input_char(n2, expression))
number_3 = Button(frame, text=n3, width = 5,command = lambda: input_char(n3, expression))
number_4 = Button(frame, text=n4, width = 5,command = lambda: input_char(n4, expression))
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询