repl.it
@CPUSkull/

CivEditor

Tkinter

i dont know... how to write python?

fork
loading
Files
  • main.py
  • civilizations_informations
  • flag
  • flagH
  • FlagHIO
  • FlagIO
  • Import
  • Template
  • Workspace
  • CivInfo
  • nohup.out
  • Packager files
  • requirements.txt
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
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
from tkinter import * 
from PIL import Image
from resizeimage import resizeimage
import os
import shutil
#Module install from requirements.txt

window = Tk()
window.title("CivEditor")

#Plz Input Step-by-Step
#Enter your civilization name
l1 = Label(window, text="CivName")
l1.grid(column=0, row=0)

txt = Entry(window, width=20)
txt.grid(column=1, row=0)

#Import your flag to Import folder & Enter filename + file extension
#Now you click Import
l2 = Label(window, text="Flag")
l2.grid(column=0, row=1)

gxt = Entry(window, width=20)
gxt.grid(column=1, row=1)

#Path for return to Main Directory function

#Image Processing
def flag():
  #Image resize to 68x44 for flagH
  f = open("Import/" + gxt.get(), 'r+b')
  image = Image.open(f)
  cv1 = resizeimage.resize_contain(image, [68, 44])
  cv1.save(txt.get() + "_FLH" + ".png")
  
  #Backup to flagH
  shutil.copy((txt.get() + "_FLH" + ".png"), "flagH")
  os.chdir("flagH")
  os.rename((txt.get() + "_FLH" + ".png"), txt.get() + ".png")
  os.chdir('..')
  
  #Image resize to 27x18 for flag
  cv2 = resizeimage.resize_contain(image, [27, 18])
  cv2.save(txt.get() + "_FL" + ".png")
  
  #Backup to flag
  shutil.copy((txt.get() + "_FL" + ".png"), "flag")
  os.chdir("flag")
  os.rename((txt.get() + "_FL" + ".png"), txt.get() + ".png")
  os.chdir('..')
  
  #Result will show "Flag Is Ready"
  #Now you can go to next step
  f.close()
  l4.configure(text= "Flag Is Ready!")

b1 = Button(window, text="Import", command=flag)
b1.grid(column=3, row=1)

#Enter Civilization Information
#Now you can click "Create"
l3 = Label(window, text="CivInfo")
l3.grid(column=0, row=2)

xxt = Entry(window, width=20)
xxt.grid(column=1, row=2)

#Civilization Editor file processing
def create():
  #Civilization information
  tt = open(r"CivInfo", "w+")
  tt.writelines(xxt.get())
  tt.close()
  os.rename("CivInfo", (txt.get()))
  shutil.move((txt.get()), "civilizations_informations")

  #Create Civilization folder & Move Flag to new folder
  shutil.copytree('Template', (txt.get()), "w+")
  shutil.move((txt.get()), "Workspace", "w+")
  
  shutil.move(txt.get() + "_FL" + ".png", "FlagIO")
  os.chdir("FlagIO")
  os.mkdir(txt.get())
  shutil.move(txt.get() + "_FL" + ".png", (txt.get()))
  os.chdir('..')
  
  shutil.move(txt.get() + "_FLH" + ".png", "FlagHIO")
  os.chdir("FlagHIO")
  os.mkdir(txt.get())
  shutil.move(txt.get() + "_FLH" + ".png", (txt.get()))
  os.chdir('..')
  
  #Create Civilization Name
  os.chdir("Workspace")
  p2 = txt.get();
  os.chdir(p2)
  tp = open(r"Template_NM", "w+")
  tp.writelines(txt.get())
  tp.close()
  
  #Rename needed file from Template for your civilization
  os.rename('Template', (txt.get()))
  os.rename('Template_FD', (txt.get() + "_FD"))
  os.rename('Template_NM', (txt.get() + "_NM"))
  os.chdir('..')
  
  #Result your civilization is create
  l4.configure(text= txt.get() + " Is Create")
    
b2 = Button(window, text="Create", command=create)
b2.grid(column=0, row=3)

#Result Box
l4 = Label(window, text= "Result!" + "\n")
l4.grid(column=1, row=4)
l4.configure(foreground="green")

window.mainloop()