Taking you into @Robot Age Discover Click on the blue text above and following the basic settings of our main form is the first step in visual programming. Following the code from the previous article, we create the settings of the main form step by step: import tkinter as tkw=tk

2025/06/1907:56:37 technology 1417

takes you into @ Robot Era

Discover Click on the above blue text , Follow us

Taking you into @Robot Age Discover Click on the blue text above and following the basic settings of our main form is the first step in visual programming. Following the code from the previous article, we create the settings of the main form step by step: import tkinter as tkw=tk - DayDayNews


Main form
's basic settings are the first step in visual programming.

Following the code from the previous article, we create the settings of the main form step by step:

import tkinter as tkw=tk.Tk()w.title=('Application of form icon')w.iconbitmap('1.ico')w.mainloop()

Add a code: w.geometry('500x260') can set the size of the window, that is:

Taking you into @Robot Age Discover Click on the blue text above and following the basic settings of our main form is the first step in visual programming. Following the code from the previous article, we create the settings of the main form step by step: import tkinter as tkw=tk - DayDayNews

What should we do if we want to set the background color of form ? Code: w['bg']='#898763', you can also use English colors instead:

import tkinter as tkw=tk.Tk()w.title=('Application of Form Icon')w.iconbitmap('1.ico')w.geometry('500x260')w['bg']='#898763'w.mainloop()

After running:

Taking you into @Robot Age Discover Click on the blue text above and following the basic settings of our main form is the first step in visual programming. Following the code from the previous article, we create the settings of the main form step by step: import tkinter as tkw=tk - DayDayNews

If we want to position the position of the form in the middle of the screen, if your monitor is 1920x1080, and how to write code for the form 500x260?

Obviously, (1920-500)/2=710 is the position of your form on the x-axis, (1080-260)/2=410 is the position of the y-axis. Let's give it a try and modify the code w.geometry('500x260') to w.geometry('500x260+710+410').

If you want to be beautiful, you don't want the user to adjust the size of the main form at will, you just need to add the code:

w.resizable(width=False,height=False)

If you don't want the title bar of the main form, you can add the following code:

w.overrideredirect(True)

Run as follows:

Taking you into @Robot Age Discover Click on the blue text above and following the basic settings of our main form is the first step in visual programming. Following the code from the previous article, we create the settings of the main form step by step: import tkinter as tkw=tk - DayDayNews

At this time, we need to add some buttons or text controls to enrich our interface.

def closed():w.destroy()tk.Button(w,text='Close window',command=closed).place(x=240,y=210)

We add a button to realize the function of closing the window. Use the place method to locate the button below the main form, and use the closed function to realize the function of closing the window.

Taking you into @Robot Age Discover Click on the blue text above and following the basic settings of our main form is the first step in visual programming. Following the code from the previous article, we create the settings of the main form step by step: import tkinter as tkw=tk - DayDayNews

However, this button does not match the interface, making it out of place.Let's adjust it:

tk.Button(w,text='Close window',command=closed,relief='solid',bg='#898763',bd=1,font=('Microsoft Yahei',8)).place(x=240,y=210)

relief sets the 3D type of the button, bg sets the background color of the button, bd is the width of the button border, fonttml2 is set as shown in the code, the font size is set to 8, the running effect:

Taking you into @Robot Age Discover Click on the blue text above and following the basic settings of our main form is the first step in visual programming. Following the code from the previous article, we create the settings of the main form step by step: import tkinter as tkw=tk - DayDayNews

is much better? Now we add a Label tag to display the text:

tk.Label(w,text="Work Robot Era WeChat Public Platform Welcomes You!",relief='solid',bg="#838181",fg="yellow",font=('Microsoft Yahei', 10), highlightbackground='#838181').place(x=30,y=50)

The effect is as follows:

Taking you into @Robot Age Discover Click on the blue text above and following the basic settings of our main form is the first step in visual programming. Following the code from the previous article, we create the settings of the main form step by step: import tkinter as tkw=tk - DayDayNews

Adjust the style:

tk.Label(w,text="Work Robot Era WeChat Public Platform Welcomes You!",bg='#898763',relief='solid',bd=0,fg="#3d3b19",font=('Microsoft Yahei', 10), highlightbackground='#838181').place(x=20,y=30)


The effect is as follows:

Taking you into @Robot Age Discover Click on the blue text above and following the basic settings of our main form is the first step in visual programming. Following the code from the previous article, we create the settings of the main form step by step: import tkinter as tkw=tk - DayDayNews


is much more beautiful? The main form is set OK!

Remember Collection Maybe you will be able to use it one day!

Previous review:

  • Come on, I will give you a gold medal sales robot, 7X24 hours a day, don’t use the salary for free! How can
  • RPA technology be reborn in travel agency sales business? ?
  • [Salary triple] Series: Get the Nine Palace Picture Cutting Robot in one move, making your circle of friends more cool!

Related content cited and excerpted by this article, please contact us to delete it if infringes.

- END -

Finally, the article will help you [ Likes and watch ] Inspire Inspire us to share more information!

technology Category Latest News