Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Window in python

#If using tkinter
import tkinter as tk
from tkinter import*
#Window creating
root = tk.Tk()
# Defining name
name = "First window"
# Setting window
root.title(name)
# IF want to use geometry So let me tell that no need of that at all
# Tkinter sets the window according to data or things inside it
# Adding button
Button bt1 = Button(root, text = "Simple click");
# Making function
def doer():
  # Print is for console
  print("Did well");
# Adding button with function
Button bt2 = Button(root, text = "Function", command = doer)
# If you will add () it after brackets it will run automatically
# Adding buttons
bt1.pack()
bt2.pack()
root.mainloop()
# This can show error If using pycharm reformat file
# Set it as you are best
Comment

window in python

#We will use tkinter for now
from tkinter import *
import tkinter as tk
#After importing tkinter we can give any name to our window for storing it
screen = Tk()
#Now we can add title to window using .title()
screen.title("VScoder tutorial how to create a window")
#You may set a size
screen.geometory("400x600")
#For now we will add a label and later you may add other items
Firstlabel = Label(screen, text="Hi")
#We may config and change background and text color or foreground
Firstlabel.config(bg="Red", fg="Blue")
#We can pack it or grid it , for now I will pack it ,Grid is for a special 
#location
Firstlabel.pack()
#Now to add it create a mainloop
screen.mainloop()
Comment

python make a new window

from PyQt5.QtWidgets import QApplication, QWidget
import sys


class Window(QWidget):
    def __init__(self):
        super().__init__()





app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
Comment

create a window in python

I`ve explaned it in detail over here 
			/
https://youtu.be/KfW3GzhyWUM
Comment

How To Make A Window Python

#Window Script
import tkinter as tk

root = tk.Tk()

canvas = tk.Canvas(root, height=600, width=1000, bg="#f0f0f0") #canvas set to #f0f0f0 to hide the canvas but change the scaling settings
canvas.pack()

frame = tk.Frame(root, bg="#f0f0f0") #f0f0f0 is the light gray default color for windows in windows 10/11
frame.place(relwidth=1.0, relheight=1.0, relx=0.1, rely=0.1) #auto center the canvas

root.mainloop()
#open with python instead of your code editor
Comment

PREVIOUS NEXT
Code Example
Python :: python between inheritance and composition 
Python :: calculate quantiles python 
Python :: Python using webbrowser 
Python :: python is not clickable at point (434, 682). Other element would receive the click: 
Python :: flask on gevent over https 
Python :: pandas resample friday 
Python :: add gaussian noise python 
Python :: how to get the length of a string in python 
Python :: numpy find mean of array 
Python :: How to install a python packagae 
Python :: append a dataframe to an empty dataframe 
Python :: simple heatmap 
Python :: string to list python 
Python :: ImportError: cannot import name include 
Python :: how to make a timer using python 
Python :: django from 
Python :: python os.remove permissionerror winerror 5 access is denied 
Python :: how to code a trading bot in python 
Python :: Identify Null and NAN python 
Python :: what is the difference between accuracy and loss 
Python :: circular cropping of image in python 
Python :: stack details in python 
Python :: python IndexError: list assignment index out of range 
Python :: how to write if statement in one line python 
Python :: snapchat api in python 
Python :: numpy arange float step 
Python :: array in python 
Python :: change order of barh matplotlib 
Python :: pyqt5 line edit font size 
Python :: python why call super(class).__init__() 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =