-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
84 lines (77 loc) · 2.02 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import tkinter as tk
from tkinter import Frame, Label, StringVar, OptionMenu
# Options that need text boxes:
# - level-name
# - level-seed
# - motd
options = {
'difficulty': {
'Peaceful': 0,
'Easy': 1,
'Normal': 2,
'Hard': 3
},
'gamemode': {
'Survival': 0,
'Creative': 1,
'Adventure': 2,
'Spectator': 3
},
'generate-structures': {
'Yes': 'true',
'No': 'false'
},
'level-type' : {
'Default': 'DEFAULT',
'Flat': 'FLAT',
'Large Biomes': 'LARGEBIOMES',
'Amplified': 'AMPLIFIED',
'Customized': 'CUSTOMIZED'
},
'pvp': {
'Yes': 'true',
'No': 'false'
},
'spawn-animals': {
'Yes': 'true',
'No': 'false'
},
'spawn-monsters': {
'Yes': 'true',
'No': 'false',
},
'spawn-npcs': {
'Yes': 'true',
'No': 'false'
}
}
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.pack()
self.options = {}
self.createWidgets()
self.loadConfig()
def loadConfig(self):
data = open('C:/Users/Edward/Dropbox/minecraft/server/ann_server.properties', 'r').readlines()
for line in data:
if line.startswith('#'): continue
key, value = line.strip().split('=')
if key in options:
self.options.get(key).set(value)
def createWidgets(self):
self.sayHi = tk.Button(self)
self.sayHi["text"] = "Eds Button"
self.sayHi["command"] = self.say_Hello
self.sayHi.pack(side="bottom")
for option in options:
f = Frame(self)
f.pack(side="bottom")
Label(f, text=option).pack(side="left")
v = StringVar(self)
o = OptionMenu(f, v, *options.get(option).values())
o.pack(side="right")
self.options[option] = v
root = tk.Tk()
app = Application(master=root)
app.mainloop()