鱼C论坛

 找回密码
 立即注册
查看: 1016|回复: 3

为什么窗口组件不能共存,他们之间有什么冲突吗??????

[复制链接]
发表于 2018-6-7 21:31:04 | 显示全部楼层 |阅读模式
1鱼币
当我把代码当中的label和entry和button这些对象都注释掉的时候,就能正常显示如图一,我把label和entry和button这些对象单独拿出去新建一个文件也能正常显示如图二
图一代码:
import tkinter
from tkinter import ttk
from tkinter.ttk import Treeview


win=tkinter.Tk()
win.title('股票数据')
'''
labelCode=Label(win,text='证券代码 :')
labelCode.place(x=10,y=5,width=53,height=20)

entryCode=Entry(win)
entryCode.place(x=65,y=5,width=51,height=20)
entryCode.focus()
entryCode.insert(0,'600000')

judgeCode=Button(win,text='判 断',command=judgeCode)
judgeCode.place(x=123,y=5,width=50,height=20)
'''
frame=tkinter.Frame(win)
frame.place(x=10,y=50)
win.geometry('1863x500')
tree=Treeview(frame,columns=('股票代码','股票简称','今日开盘','昨日收盘','现价','今日最高','今日最低',
                            '买一价格','卖一价格','成交数量','成交金额','买一量','买一价','买二量','买二价','买三量',
                            '买三价','买四量','买四价','买五量','买五价','卖一量','卖一价','卖二量','卖二价','卖三量',
                            '卖三价','卖四量','卖四价','卖五量','卖五价','日期','时间','校验'),show='headings')
tree.column('股票代码',width=60, anchor='center')
................
tree.heading('股票代码',text='股票代码')
................
tree.pack(side=tkinter.LEFT, fill=tkinter.Y)
win.mainloop()
其中.................是因为制表太多项目都省略没有


图二代码:
from tkinter import *

def judgeCode():
    stockCode=entryCode.get()
    print('你输入的证券代码是: %s' % stockCode)
    if len(stockCode)!=6:
                print('输入的股票代码无法识别!')
                entryCode.delete(0,END) 
                return
            
    firstNum=stockCode[0]
    thirdNum=stockCode[0:3]

    if firstNum=='6':
            print('属于上海交易所代码')              
                
    elif firstNum=='3' or thirdNum=='000' or thirdNum=='002':
            print('属于深圳交易所代码')
            
    else:
                print('输入的股票代码无法识别!')

    entryCode.delete(0,END)  

win=Tk()
win.title('股票数据')
win['height']=600
win['width']=1900

labelCode=Label(win,text='证券代码 :')
labelCode.place(x=10,y=5,width=53,height=20)

entryCode=Entry(win)
entryCode.place(x=65,y=5,width=51,height=20)
entryCode.focus()
entryCode.insert(0,'600000')

judgeCode=Button(win,text='判 断',command=judgeCode)
judgeCode.place(x=123,y=5,width=50,height=20)

mainloop()

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2018-6-9 01:06:31 | 显示全部楼层
请不要沉
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2018-6-9 01:07:09 | 显示全部楼层
防沉回复,希望更多人看到
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2018-6-9 09:33:50 | 显示全部楼层
自己顶贴不要沉,请路过的大侠出手相助
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-6-24 02:41

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表