-
Notifications
You must be signed in to change notification settings - Fork 1
/
gui.py
54 lines (44 loc) · 1.87 KB
/
gui.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
# -*- coding: utf-8 -*-
import os
from tkinter import Frame, Entry, Button, Radiobutton, IntVar
import tkinter as tk
import configparser
class Application(Frame):
"""
configure should only be changed here!
"""
def __init__(self, master=None):
self.cfg = configparser.ConfigParser()
self.cfg.read('settings.ini')
Frame.__init__(self, master)
self.pack()
self.createWidgets()
def createWidgets(self):
v = IntVar()
v.set(1)
self.checkbutton_selection = Radiobutton(self, text='selection', font=('Monaco', 20), value=1, variable=v,
command=self.choose_selection_mode)
self.checkbutton_selection.pack()
self.checkbutton_random_init = Radiobutton(self, text='random init', font=('Monaco', 20), value=2, variable=v,
command=self.choose_random_init_mode)
self.checkbutton_random_init.pack()
self.checkbutton_readfile = Radiobutton(self, text='read file', font=('Monaco', 20), value=3, variable=v,
command=self.choose_readfile_mode)
self.checkbutton_readfile.pack()
def choose_selection_mode(self):
self.cfg.set('MODE', 'mode', 'SELECTION')
with open('settings.ini', 'w') as configfile:
self.cfg.write(configfile)
def choose_random_init_mode(self):
self.cfg.set('MODE', 'mode', 'RANDOM_INIT')
with open('settings.ini', 'w') as configfile:
self.cfg.write(configfile)
def choose_readfile_mode(self):
self.cfg.set('MODE', 'mode', 'READFILE')
with open('settings.ini', 'w') as configfile:
self.cfg.write(configfile)
if __name__ == '__main__':
root = tk.Tk()
root.geometry("500x500")
app = Application(master=root)
app.mainloop()