至尊宝___
发表于 2017-12-12 14:41:34
因吹斯听
996211706
发表于 2017-12-14 18:03:15
{:10_266:}
早起的达仙僧
发表于 2017-12-16 09:59:30
分享一个错误案例:如果将程序的名字命名为tkinter.py,在pycharm里运行时会报错 AttributeError: module 'tkinter' has no attribute 'Tk'
解决方案:修改文件名。
参考:https://stackoverflow.com/questions/34404478/tkinter-in-python3-anaconda-attributeerror-module-tkinter-has-no-attribut
2653447782
发表于 2017-12-21 17:49:12
{:10_269:}
你不知道我名字
发表于 2017-12-27 10:09:12
123
skyli2007
发表于 2017-12-30 20:54:09
在哪里下载呢……
skyli2007
发表于 2017-12-30 20:57:11
知道了
摆渡终极鉴黄师
发表于 2018-1-1 13:40:14
好东西,蟹蟹小甲鱼老湿{:10_281:}
阳明先生
发表于 2018-1-3 22:20:23
学习了~
zhujiasheng1987
发表于 2018-1-23 10:46:48
这里好像有点问题,等于是pack()后再赋值给了w了,似乎应该如下写哈
v = StringVar()
w = Label(master,textvariable = v)
w.pack()
v.set("~新的文本~")
341818178
发表于 2018-2-21 20:13:12
学习了,很详细呀,支持下
大艾尔
发表于 2018-3-2 16:29:29
求助:我这个计算器在按数字的过程中,label1、label2的显示数字不会变化???
from tkinter import *
master = Tk()
group2 = LabelFrame(master).grid(padx=0, pady=0)
group1 = LabelFrame(master).grid(padx=0, pady=50)
# 存放正在输入的数字、以及两个用于实际计算的数字:
num = []
operator = ''
operator_result = 0
num_result = 0
counter1 = 0
counter2 = 0
def num_get():
num2 = num.copy()
num1 = ''
global num_result
if num2[-1] == '.':
num2.append('0')
for each in num2:
num1 += each
num_result = float(num1)
print(num_result)
def cbp():
num.append('.')
num_get()
def cb0():
num.append('0')
num_get()
def cb1():
num.append('1')
num_get()
def cb2():
num.append('2')
num_get()
def cb3():
num.append('3')
num_get()
def cb4():
num.append('4')
num_get()
def cb5():
num.append('5')
num_get()
def cb6():
num.append('6')
num_get()
def cb7():
num.append('7')
num_get()
def cb8():
num.append('8')
num_get()
def cb9():
num.append('9')
num_get()
def cba():
global num, operator, operator_result, num_result, counter1, counter2
if not counter1:
counter1 = num_result
else:
counter2 = num_result
num = []
operator = '+'
def cbm():
global num, operator, operator_result, num_result, counter1, counter2
if not counter1:
counter1 = num_result
else:
counter2 = num_result
num = []
operator = '-'
def cbl():
global num, operator, operator_result, num_result, counter1, counter2
if not counter1:
counter1 = num_result
else:
counter2 = num_result
num = []
operator = '*'
def cbd():
global num, operator, operator_result, num_result, counter1, counter2
if not counter1:
counter1 = num_result
else:
counter2 = num_result
num = []
operator = '/'
def cbe():
global num, operator, operator_result, num_result, counter1, counter2
if not counter1:
operator_result = counter1
else:
counter2 = num_result
if operator == '+':
operator_result = counter1 + counter2
if operator == '-':
operator_result = counter1 - counter2
if operator == '*':
operator_result = counter1 * counter2
if operator == '/':
operator_result = counter1 / counter2
print(operator_result)
counter1 = operator_result
def cbc():
global num, operator, operator_result, num_result, counter1, counter2
num = []
operator = ''
operator_result = 0
num_result = 0
counter1 = 0
counter2 = 0
# 数字1-9
bp = Button(group1, text = '.', width = 2, command = cbp)
bp.grid(row=7, column=2)
b0 = Button(group1, text = '0', width = 6, command = cb0)
b0.grid(row=7, column=0, columnspan=2)
b1 = Button(group1, text = '1', width = 2, command = cb1)
b1.grid(row=6, column=0)
b2 = Button(group1, text = '2', width = 2, command = cb2)
b2.grid(row=6, column=1)
b3 = Button(group1, text = '3', width = 2, command = cb3)
b3.grid(row=6, column=2)
b4 = Button(group1, text = '4', width = 2, command = cb4)
b4.grid(row=5, column=0)
b5 = Button(group1, text = '5', width = 2, command = cb5)
b5.grid(row=5, column=1)
b6 = Button(group1, text = '6', width = 2, command = cb6)
b6.grid(row=5, column=2)
b7 = Button(group1, text = '7', width = 2, command = cb7)
b7.grid(row=4, column=0)
b8 = Button(group1, text = '8', width = 2, command = cb8)
b8.grid(row=4, column=1)
b9 = Button(group1, text = '9', width = 2, command = cb9)
b9.grid(row=4, column=2)
# 运算符号
ba = Button(group1, text = '+', width = 4, height = 3, command = cba)
ba.grid(row=4, rowspan=2, column=3)
bm = Button(group1, text = '-', width = 4, command = cbm)
bm.grid(row=3, column=3)
bp = Button(group1, text = '*', width = 2, command = cbl)
bp.grid(row=3, column=2)
bd = Button(group1, text = '/', width = 2, command = cbd)
bd.grid(row=3, column=1)
be = Button(group1, text = 'Enter', width = 4, height = 3, command = cbe)
be.grid(row=6, rowspan=2, column=3)
bc = Button(group1, text = 'c', width = 2, command = cbc)
bc.grid(row=3, column=0)
# 运算结果
v1 = StringVar()
label1 = Label(group2, background="white", textvariable=v1).grid(row=1, rowspan=4)
v1.set(str(operator_result))
v2 = StringVar()
label2 = Label(group2, background="white", textvariable=v2).grid(row=0, rowspan=4)
v2.set(str(counter1) + str(operator) + str(counter2))
mainloop()
tanteshenma
发表于 2018-3-19 21:36:40
有点木了
yinzhipeng123
发表于 2018-3-30 22:21:01
vip能看付费主题吗???
小杨爱编程
发表于 2018-4-3 16:52:32
{:10_266:}
wangzhezhixin
发表于 2018-4-4 09:59:25
看不到内容,谁能送我一点鱼币呢?
清风明月寄相思
发表于 2018-4-22 16:28:26
有点复杂啊{:10_266:}{:10_266:}
wangzhezhixin
发表于 2018-4-26 08:36:40
哈哈,不付费?我书都买了
742277203
发表于 2018-5-6 14:51:17
为什么entry组件没有get delete insert这些方法啦
742277203
发表于 2018-5-10 10:39:34
小甲鱼,请问一下,最后事件循环的时候使用root.mainloop()还是tkinter.mainloop()呢?
页:
1
2
3
4
[5]
6
7
8
9
10