-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile_window.py
More file actions
129 lines (96 loc) · 3.6 KB
/
profile_window.py
File metadata and controls
129 lines (96 loc) · 3.6 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# -*- coding: utf-8 -*-
import gi
import dataRead
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
# from dataRead import read_profile
versions = ["1.7.10", "1.8", "1.8.1", "1.9", "1.9.4"]
# ["Name of profile", "version"],
profile_list_l = dataRead.read_profile()
profile_list_gui = Gtk.ComboBoxText()
class ProfileWindow(Gtk.Window):
def __init__(self):
window = Gtk.Window()
window.set_title("ToolsCraft - Profile")
window.set_position(Gtk.WindowPosition.CENTER)
window.connect("delete-event", Gtk.main_quit)
#Boxs
main_box = Gtk.Box()
main_box.set_spacing(2)
main_box.set_orientation(Gtk.Orientation.HORIZONTAL)
window.add(main_box)
lbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
lbox.set_spacing(5)
main_box.add(lbox)
rbox = Gtk.Box()
rbox.set_spacing(15)
rbox.set_orientation(Gtk.Orientation.VERTICAL)
main_box.add(rbox)
#Items
profile_label = Gtk.Label("Choose a profile :")
lbox.add(profile_label)
for profile in profile_list_l:
profile_list_gui.append_text(profile[0])
profile_list_gui.set_entry_text_column(0)
lbox.add(profile_list_gui)
open_profile = Gtk.Button("Choose this profile")
open_profile.connect_after("clicked", self.on_open_clicked)
lbox.add(open_profile)
create = Gtk.Button("Create a new profile")
create.connect_after("clicked", self.create_new_profile)
lbox.add(create)
delete = Gtk.Button("Delete this profile")
delete.connect_after("clicked", self.delete_profile)
lbox.add(delete)
window.show_all()
def on_open_clicked(self, button):
# To implement ! (Open the mod window !)
pass
def create_new_profile(self, button):
CreationWindow()
Gtk.main()
Gtk.main_quit()
def delete_profile(self, button):
active = profile_list_gui.get_active()
profile_list_l.pop(active)
profile_list_gui.remove(active)
profile_list_gui.set_active(0)
dataRead.write_profile(profile_list_l)
class CreationWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Create a new profile - ToolsCraft")
self.connect("delete-event", Gtk.main_quit)
box = Gtk.Box(spacing=5, orientation=Gtk.Orientation.HORIZONTAL)
self.add(box)
lb = Gtk.Label("Choose options for your new profile :")
box.add(lb)
self.name = Gtk.Entry()
box.add(self.name)
self.versions_list = Gtk.ComboBoxText()
for version in versions:
self.versions_list.append_text(version)
box.add(self.versions_list)
create = Gtk.Button("Create this profile !")
create.connect_after("clicked", self.add_profile)
cancel = Gtk.Button("Cancel !")
cancel.connect_after("clicked", self.cancel)
box.add(create)
box.add(cancel)
self.show_all()
def add_profile(self, button):
for profile in profile_list_l:
if(self.name.get_text() in profile):
Gtk.main_quit()
quit()
profile_list_l.append([self.name.get_text(),
self.versions_list.get_active_text()])
count = 0
for profile in profile_list_l:
profile_list_gui.remove(count)
count += 1
for profile in profile_list_l:
profile_list_gui.append_text(profile[0])
dataRead.write_profile(profile_list_l)
def cancel(self, button):
Gtk.main_quit()
quit()