Let's make a simple software for studying python!
I will try to make one software with tkinter with enthusiasm. For the time being, software that changes settings on Windows.
The name is "Let's go home"
I started making it with the concept of "I hope it will be convenient to change settings".
It would be great if we could provide people who want to make Windows setting change software with a little helpful information!
After investigating, it seems that the UI design is different between tkinter and tkinter.ttk. ttk has a more modern UI.
Furthermore, the development of PySimpleGUI started in 2018, and it seems that the code is short and the GUI can be assembled with a more modern design.
There is a lot of information on NET this time, so let's challenge with tkinter! That's why I started creating it.
It's like this. Yup. It's okay to look like an amateur's work lol
For the time being, I implemented the following. ・ PC name change ・ IPv4 change -Automatic logon
At first, I was thinking only about "changing the PC name", but the number of functions I want to implement later has increased steadily. ..
I made changes to the UI each time, so this was a hassle for Moretz. No, it's really stupid. Yup. The idea is no good
I started making it with this kind of glue, but the function itself of the above image has come to work properly.
Since Windows has problems with permissions and UAC, it is necessary to suppress the movement and make the change complete.
In addition, process.run, registry writing, input character check and log output implementation, pyramor, exe conversion, module division, etc. are included, and after restarting, the program is automatically started as step2.
It would be nice if we could release free software if we could debug and brush up, but I think it's still a long way off.
But, after all, By making one thing, you can see the flow of one series! I learned a lot.
class Application(tk.Frame):
def __init__(self, master):
super().__init__(master)
self.pack()
self.master.geometry("620x630")
self.master.title("Let's go home")
nb = ttk.Notebook(width=200, height=200)
The menu bar looks like this.
#Creating a menu bar
self.menubar = tk.Menu(master)
master.configure(menu = self.menubar)
#File menu
filemenu = tk.Menu(self.menubar, tearoff = 0)
self.menubar.add_cascade(label = "File", menu = filemenu)
#~ Contents
filemenu.add_command(label = "Read from file(In development)")
#~ Contents
filemenu.add_command(label = "Save to file(In development)")
#separator
filemenu.add_separator()
filemenu.add_command(label = "End", command = lambda: master.destroy())
Tab implementation
#tab
tab1 = tk.Frame(nb)
tab2 = tk.Frame(nb)
tab3 = tk.Frame(nb)
tab4 = tk.Frame(nb)
self.textbox1 = tk.Text(tab4)
self.textbox1.configure(font=("", 14, ""))
self.textbox1.pack()
self.textbox1.place(x=150, y=0,width = 460, height = 570)
tab5 = tk.Frame(nb)
By the way, tab4 implements textbox.
For example, it would be convenient if you could paste parameters from Excel and change the settings, right? What an idea. The implementation itself is not difficult.
You can read it from a CSV file, or decide how to put the data in this area according to the operation!
So if you want to make a judgment, powershell may be better.
This time, I changed the computer name with powershell and judged the return value to judge normal or abnormal.
Judgment is OK if you get the parameter from the registry and compare it with the changed value. Note that even if you simply type ipconfig, it will not be output when offline.
If you refer to the registry, you can also output interfaces such as "Ethernet" in a list.
import ipaddress as ipadd
def chk_ipv4(self,ipaddress):
try:
ipadd.ip_address(ipaddress)
return "ok"
except ValueError:
return "ng"
I myself studied python and made it in about 2 months.
However, I think it is difficult to make it if you do not understand the movement of Windows.
It didn't work when I made it an exe normally.
Recommended Posts