
# ############################################################## #
# - ABOUT THE PROGRAM -
# Program name : open new window app
# Program description : opens new window on button click
# Author : Abdur-Rahmaan Janhangeer
# Date : 7th of May 2017
# License : MIT with emphasis :
# You are free to modify and distribute the program provided that
# attribution is C L E A R L Y made.
# Python version : Python 3.4
# ############################################################# #
# ############################################################# #
# - INDEX -
# 1 import statement/s
# 2 root / master definition
# 3 Function definition
# 4 Button
# 5 mainloop
# ############################################################# #
# ############################################################# #
# - CONVENTIONS USED -
# --- naming ---
# functions : function names end with F
# Button named button1 . . .
# ############################################################# #
# ############################################################# #
# - NOTES AND WARNINGS -
# ---warning---
# wildcard operator used in imports
# ---notes---
# one shot comments used
# ############################################################# #
from tkinter import *
root = Tk()
def new_winF(): # new window definition
newwin = Toplevel(root)
display = Label(newwin, text="Humm, see a new window !")
display.pack()
button1 =Button(root, text ="open new window", command =new_winF) #command linked
button1.pack()
root.mainloop()
view the examples repo
In need of managing bookmarks online? Try the awesome Bookmark Ninja
Like this:
Like Loading...
Here is some similar code I wrote:
LikeLiked by 1 person
Yes,Nice !
LikeLiked by 1 person
forgot to congratulate you for resolving python2 and 3
LikeLiked by 1 person
Yeah, tkinter’s name is different between the versions of python.
LikeLike
I have two question, I’d like the windows to be in the same position on the screen, is it possible to definethe relative position?
SEcond I want to make a fron end for a set of tools so I need more buttons and buttons within the new windows to allow selection of options.
where do I put my code for each tool / process?
do you need to have an exit button?
Sorry more than two questions
LikeLike
how would you add an image into the new window?
LikeLike