Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

maelgruandWebDev/tutorialWindowPython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Create a window using an exernal file

File name : window.py

compile file in a venv environement :

mkdir PythonTuto
cd PythonTuto
# For linux (module venv of Python)
python3 -m venv env
# Windows
python -m venv env

#code into the env using command
# Linux
source env/bin/activate

# Window
env/Scripts/activate

Python Code example using Tkinter

#Linux and Window --> in venv
pip install tkinter
# Or
sudo apt install python3-tk

External file

window.py :
import tkinter as tk

#traditional form
root = tk.Tk()
root.geometry("500x500")
root.title("Tkinter tutorial")

root.mainloop()


# My form
def createWindow(title, size):
    window = tk.Tk()
    window.geometry(size)
    window.title(title)
    return window

In the main script :

main.py
import window as win

root = win.createWindow("A Tk window", "500x500")
root.mainloop

Releases

No releases published

Packages

No packages published

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.