鱼C论坛

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

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

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


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

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

  13. judgeCode=Button(win,text='判 断',command=judgeCode)
  14. judgeCode.place(x=123,y=5,width=50,height=20)
  15. '''
  16. frame=tkinter.Frame(win)
  17. frame.place(x=10,y=50)
  18. win.geometry('1863x500')
  19. tree=Treeview(frame,columns=('股票代码','股票简称','今日开盘','昨日收盘','现价','今日最高','今日最低',
  20.                             '买一价格','卖一价格','成交数量','成交金额','买一量','买一价','买二量','买二价','买三量',
  21.                             '买三价','买四量','买四价','买五量','买五价','卖一量','卖一价','卖二量','卖二价','卖三量',
  22.                             '卖三价','卖四量','卖四价','卖五量','卖五价','日期','时间','校验'),show='headings')
  23. tree.column('股票代码',width=60, anchor='center')
  24. ................
  25. tree.heading('股票代码',text='股票代码')
  26. ................
  27. tree.pack(side=tkinter.LEFT, fill=tkinter.Y)
  28. win.mainloop()
复制代码

其中.................是因为制表太多项目都省略没有


图二代码:
  1. from tkinter import *

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

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

  20.     entryCode.delete(0,END)  

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

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

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

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

  33. mainloop()
复制代码

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2018-6-9 01:06:31 | 显示全部楼层
请不要沉
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2018-6-9 01:07:09 | 显示全部楼层
防沉回复,希望更多人看到
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2018-6-9 09:33:50 | 显示全部楼层
自己顶贴不要沉,请路过的大侠出手相助
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-13 02:14

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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