鱼C论坛

 找回密码
 立即注册
查看: 2281|回复: 4

python文件编译为exe文件

[复制链接]
发表于 2017-3-10 21:39:55 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
python版本3.6
安装pyinstaller 后编译 .py文件显示 IndexError: tuple index out of range
捕获.PNG
无经验新手,不知如何解决
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-3-10 22:01:25 | 显示全部楼层
贴下代码吧 这应该是代码的问题,光看这些错误看不出来的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-3-10 22:09:53 | 显示全部楼层
  1. from tkinter import *
  2. from tkinter import filedialog
  3. import pygame
  4. pygame.mixer.init()
  5. pygame.mixer.music.set_volume(0.2)
  6. signal_1 = 0
  7. volume = 0.1
  8. NAME_1 = []
  9. NAME_2 = []
  10. INDEX = 0
  11. NAME = ''
  12. def get(event):
  13.     button2['state'] = ACTIVE
  14.     button4['state'] = DISABLED
  15.     global NAME
  16.     global INDEX
  17.     try:
  18.         NAME = lib.get(lib.curselection())
  19.         INDEX = lib.curselection()[0]
  20.     except:
  21.         pass
  22. def play():
  23.     global signal_1
  24.     global NAME
  25.     signal_1 =signal_1
  26.     if  signal_1 ==1:
  27.         pygame.mixer.music.unpause()
  28.         signal_1 = 0
  29.         button2['state'] = DISABLED
  30.         button3['state'] = ACTIVE
  31.         button4['state'] = ACTIVE
  32.         
  33.     else:
  34.         pygame.mixer.music.load(NAME)
  35.         pygame.mixer.music.play()
  36.         print(lib.get(INDEX+1))
  37.         pygame.mixer.music.queue(lib.get(INDEX+1))
  38.         button2['state'] = DISABLED
  39.         button3['state'] = ACTIVE
  40.         button4['state']= ACTIVE
  41. def pause():
  42.     pygame.mixer.music.pause()
  43.     global siganl_1
  44.     signal_1=1
  45.     button2['state'] = ACTIVE
  46.    
  47.     button4['state'] = DISABLED
  48. def nextsong():
  49.     global INDEX
  50.     global NAME
  51.     INDEX = INDEX+1
  52.     NAME = lib.get(INDEX)
  53.     play()
  54. def lastsong():
  55.     global INDEX
  56.     global NAME
  57.     INDEX = INDEX-1
  58.     NAME = lib.get(INDEX)
  59.     play()
  60. def playback():
  61.     global signal_1
  62.     signal_1 = 0
  63.     pygame.mixer.music.rewind()
  64. def volumeup():
  65.     global volume
  66.     if volume >=1.0:
  67.         button6['state'] = DISABLED
  68.         button7['state'] = ACTIVE
  69.     else:
  70.         volume = volume+0.05
  71.         button6['state'] = ACTIVE
  72.         button7['state'] = ACTIVE
  73.         pygame.mixer.music.set_volume(volume)
  74. def volumedown():
  75.     global volume
  76.     if volume <=0:
  77.         button7['state'] = DISABLED
  78.         button6['state'] = ACTIVE
  79.     else:
  80.         volume = volume-0.05
  81.         button6['state'] = ACTIVE
  82.         button7['state'] = ACTIVE
  83.         pygame.mixer.music.set_volume(volume)
  84. def openfile():
  85.     global NAME_1
  86.     global NAME_2
  87.     NAME_1 = filedialog.askopenfilenames(filetypes = [('MP3','.mp3')])
  88.     for name in NAME_1:
  89.         if name not in NAME_2:
  90.             NAME_2.append(name)
  91.     for item in NAME_2:
  92.         lib.insert(END,item)
  93.     lib.grid(row = 1,columnspan = 7,sticky = W)
  94.     sb.config(command = lib.yview)
  95. def savefile():
  96.     filedialog.asksaveasfilename()
  97.    
  98. root = Tk()
  99. root.title('星云播放器')
  100. root.resizable(False, False)
  101. sb = Scrollbar(root)
  102. sb.grid(row = 1,column = 7,sticky = W,ipady = 80)
  103. lib = Listbox(root,height = 12,width = 59,yscrollcommand = sb.set)
  104. lib.bind("<ButtonRelease-1>",get)
  105. lib.grid(row = 1,columnspan = 7,sticky = W)
  106. sb.config(command = lib.yview)
  107. menubar = Menu(root)
  108. filename = Menu(menubar,tearoff = False)
  109. filename.add_command(label = '打开',command = openfile)
  110. filename.add_command(label = '保存',command = savefile)
  111. menubar.add_cascade(label = '文件',menu = filename)
  112. root.config(menu = menubar)
  113. button1 = Button(root,text = "上一首",width = 7,height = 1,command = lastsong)
  114. button1.grid(row = 2,column = 0,sticky = W)

  115. button2 = Button(root,text = '播放',width = 7,height = 1,command = play,state = ACTIVE)
  116. button2.grid(row = 2,column=1,sticky = W)

  117. button3 = Button(root,text = '重新播放',width = 7,height = 1,command = playback,state = DISABLED)
  118. button3.grid(row = 2,column=2,sticky = W)

  119. button4 = Button(root,text = '暂停',width = 7,height = 1,command = pause,state = DISABLED)
  120. button4.grid(row = 2,column=3,sticky = W)

  121. button5 = Button(root,text = "下一首",width = 7,height = 1,command = nextsong)
  122. button5.grid(row = 2,column=4,sticky = W)

  123. button6 = Button(root,text = "音量+",width = 7,height = 1,command = volumeup)
  124. button6.grid(row = 2,column=5,sticky = W)

  125. button7 = Button(root,text = "音量-",width = 7,height = 1,command = volumedown)
  126. button7.grid(row = 2,column=6,sticky = W)
  127. mainloop()
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-3-10 22:34:14 | 显示全部楼层
我换了一个版本,发现问题解决了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-3-11 08:20:26 From FishC Mobile | 显示全部楼层
pyinstaller貌似还不支持puthon 3.6吧,我也是退回到以前版本编译的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-25 01:38

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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