伊莉討論區
標題:
找不到python版...IndexError: tuple index out of range
[打印本頁]
作者:
usb008
時間:
2021-11-10 10:04 PM
標題:
找不到python版...IndexError: tuple index out of range
如標題,我在打包的時候出現該錯誤,無法打包,問題是出在哪邊呢??
有人能幫忙解答嗎感謝感謝
import
tkinter
as
tk
from
PIL
import
Image
,
ImageTk
def
printInfo
():
n1
.
set
(
0
)
n12
.
set
(
0
)
n13
.
set
(
0
)
n14
.
set
(
0
)
n15
.
set
(
0
)
n16
.
set
(
0
)
n17
.
set
(
0
)
n2
.
set
(
0
)
n22
.
set
(
0
)
n23
.
set
(
0
)
n24
.
set
(
0
)
n25
.
set
(
0
)
n26
.
set
(
0
)
n27
.
set
(
0
)
def
X7
():
x1
.
set
(
7
)
def
X8
():
x1
.
set
(
8
)
def
X9
():
x1
.
set
(
9
)
#重新設定 n1~n27的值為0
def
add
():
n4
.
set
(
((
n1
.
get
()+
n12
.
get
()+
n13
.
get
()+
n14
.
get
()+
n15
.
get
()+
n16
.
get
()+
n17
.
get
())
-(
n2
.
get
()+
n22
.
get
()+
n23
.
get
()+
n24
.
get
()+
n25
.
get
()+
n26
.
get
()+
n27
.
get
()))
/
n3
.
get
()/
10
*
x1
.
get
()
)
lootall
.
set
((
n1
.
get
()+
n12
.
get
()+
n13
.
get
()+
n14
.
get
()+
n15
.
get
()+
n16
.
get
()+
n17
.
get
()-
n2
.
get
()-
n22
.
get
()-
n23
.
get
()-
n24
.
get
()-
n25
.
get
()-
n26
.
get
()-
n27
.
get
()
)*
x1
.
get
()/
10
)
#計算公式
window
=
tk
.
Tk
()
#定義 tk.Tk() 縮寫 window
window
.
title
(
"PUI loot計算機"
)
#是視窗名稱
window
.
geometry
(
'550x400'
)
#視窗大小
image
=
Image
.
open
(
"C:/Users/USB007/Desktop/python/tktktk/png.png"
)
photo
=
ImageTk
.
PhotoImage
(
image
)
label
=
tk
.
Label
(
image
=
photo
)
label
.
grid
(
row
=
10
,
column
=
1
)
#視窗固定尺寸
n1
=
tk
.
IntVar
()
n12
=
tk
.
IntVar
()
n13
=
tk
.
IntVar
()
n14
=
tk
.
IntVar
()
n15
=
tk
.
IntVar
()
n16
=
tk
.
IntVar
()
n17
=
tk
.
IntVar
()
n2
=
tk
.
IntVar
()
n21
=
tk
.
IntVar
()
n22
=
tk
.
IntVar
()
n23
=
tk
.
IntVar
()
n24
=
tk
.
IntVar
()
n25
=
tk
.
IntVar
()
n26
=
tk
.
IntVar
()
n27
=
tk
.
IntVar
()
lootall
=
tk
.
IntVar
()
n3
=
tk
.
IntVar
()
n4
=
tk
.
IntVar
()
x1
=
tk
.
IntVar
()
#建立儲存格
lab2
=
tk
.
Label
(
window
,
text
=
"loot金額"
,
relief
=
tk
.
SOLID
,
width
=
20
,
bg
=
"lightblue"
)
lab3
=
tk
.
Label
(
window
,
text
=
"loot修理費"
,
relief
=
tk
.
SOLID
,
width
=
20
,
bg
=
"lightblue"
)
lab4
=
tk
.
Label
(
window
,
text
=
"分贓人數"
,
relief
=
tk
.
SOLID
,
width
=
20
,
bg
=
"lightblue"
)
lab5
=
tk
.
Label
(
window
,
text
=
"折數"
,
relief
=
tk
.
SOLID
,
width
=
20
,
bg
=
"green"
)
lab6
=
tk
.
Label
(
window
,
text
=
"分贓總金額"
,
relief
=
tk
.
SOLID
,
width
=
20
,
bg
=
"yellow"
)
lab7
=
tk
.
Label
(
window
,
text
=
"每人分得金額"
,
relief
=
tk
.
SOLID
,
width
=
20
,
bg
=
"magenta"
)
lab9
=
tk
.
Label
(
window
,
text
=
"製作人:usb007 版本0.1測試版"
,
width
=
30
)
lab9
.
grid
(
row
=
11
,
column
=
1
)
lab2
.
grid
(
row
=
1
,
column
=
0
)
lab3
.
grid
(
row
=
1
,
column
=
1
)
lab4
.
grid
(
row
=
1
,
column
=
2
)
lab5
.
grid
(
row
=
3
,
column
=
2
)
lab6
.
grid
(
row
=
5
,
column
=
2
)
lab7
.
grid
(
row
=
7
,
column
=
2
)
e1
=
tk
.
Entry
(
window
,
textvariable
=
n1
)
e12
=
tk
.
Entry
(
window
,
textvariable
=
n12
)
e13
=
tk
.
Entry
(
window
,
textvariable
=
n13
)
e14
=
tk
.
Entry
(
window
,
textvariable
=
n14
)
e15
=
tk
.
Entry
(
window
,
textvariable
=
n15
)
e16
=
tk
.
Entry
(
window
,
textvariable
=
n16
)
e17
=
tk
.
Entry
(
window
,
textvariable
=
n17
)
e2
=
tk
.
Entry
(
window
,
textvariable
=
n2
)
e22
=
tk
.
Entry
(
window
,
textvariable
=
n22
)
e23
=
tk
.
Entry
(
window
,
textvariable
=
n23
)
e24
=
tk
.
Entry
(
window
,
textvariable
=
n24
)
e25
=
tk
.
Entry
(
window
,
textvariable
=
n25
)
e26
=
tk
.
Entry
(
window
,
textvariable
=
n26
)
e27
=
tk
.
Entry
(
window
,
textvariable
=
n27
)
e3
=
tk
.
Entry
(
window
,
textvariable
=
n3
)
e4
=
tk
.
Entry
(
window
,
textvariable
=
n4
)
x11
=
tk
.
Entry
(
window
,
textvariable
=
x1
)
loot
=
tk
.
Entry
(
window
,
textvariable
=
lootall
)
but1
=
tk
.
Button
(
window
,
text
=
"清除文字"
,
command
=
printInfo
)
but2
=
tk
.
Button
(
window
,
text
=
"計算loot"
,
command
=
add
,
bg
=
"gold"
,
height
=
8
,
width
=
15
)
but3
=
tk
.
Button
(
window
,
text
=
"七折"
,
command
=
X7
,
bg
=
"aqua"
)
but4
=
tk
.
Button
(
window
,
text
=
"八折"
,
command
=
X8
,
bg
=
"cadetblue"
)
but5
=
tk
.
Button
(
window
,
text
=
"九折"
,
command
=
X9
)
e1
.
grid
(
row
=
2
,
column
=
0
)
e12
.
grid
(
row
=
3
,
column
=
0
)
e13
.
grid
(
row
=
4
,
column
=
0
)
e14
.
grid
(
row
=
5
,
column
=
0
)
e15
.
grid
(
row
=
6
,
column
=
0
)
e16
.
grid
(
row
=
7
,
column
=
0
)
e17
.
grid
(
row
=
8
,
column
=
0
)
e2
.
grid
(
row
=
2
,
column
=
1
)
e22
.
grid
(
row
=
3
,
column
=
1
)
e23
.
grid
(
row
=
4
,
column
=
1
)
e24
.
grid
(
row
=
5
,
column
=
1
)
e25
.
grid
(
row
=
6
,
column
=
1
)
e26
.
grid
(
row
=
7
,
column
=
1
)
e27
.
grid
(
row
=
8
,
column
=
1
)
e3
.
grid
(
row
=
2
,
column
=
2
)
e4
.
grid
(
row
=
8
,
column
=
2
)
x11
.
grid
(
row
=
4
,
column
=
2
)
loot
.
grid
(
row
=
6
,
column
=
2
)
but1
.
grid
(
row
=
9
,
column
=
2
)
but2
.
grid
(
row
=
10
,
column
=
2
)
but3
.
grid
(
row
=
4
,
column
=
3
)
but4
.
grid
(
row
=
5
,
column
=
3
)
but5
.
grid
(
row
=
6
,
column
=
3
)
window
.
mainloop
()
#視窗右上關閉按鈕
歡迎光臨 伊莉討論區 (http://a04.eyny.com/)
Powered by Discuz!