Meo's Web site
     

http://www.meo-x.net

     Home | Information | Know-how | Sections | Documents | Services | Plus |

 

 

 

E-MAIL:
mail to meo-x.net  Send a mail           

 

Ein einfaches Beispiel von Python Tkinter-Grid objektorientierter Programmierung

 

Dieses Modul wurde von Didier Meo programmiert.

 

Hier wird die Entwicklungsumgebung Eclipse eingesetzt.

 

Un simple exemple pour la programmation orientée objet en Python avec Tkinter et Grid

 

Ce module a été programmé par Didier Meo.

 

L'outil PyScripter a été utilisé ici pour programmer ce module

 

A simple Tkinter Grid object oriented programming sample

 

This module was programming by Didier Meo.

 

For programming the IDE Idle (Python Shell) was used here.

 

..............................................                

	  
#-------------------------------------------------------------------------------
# Name:        MEOtkgrid1
# Purpose:
#
# Author:      Didier MEO
#
# Created:     14/05/2013
# Copyright:   (c) Didier MEO 2013
# Licence:     free MEO Education
#-------------------------------------------------------------------------------
# a simple Meo's Python - Tkinter Grid object oriented programming sample
# with Python 3.3.2
from tkinter import *

class Fenetre(Frame):

    def __init__(self, master=None):
        Frame.__init__(self, master, bg="cyan")
        self.rowconfigure(0, weight=1, minsize=200)
        self.columnconfigure(0, weight=1, minsize=200)
        self.grid()
        self.AjouterControles()

    def callNew(self):
        messagebox.showwarning(title="Meo's Tkinter Grid oo programming sample", message="Create a new file")

    def callOpen(self):
        filedialog.askopenfile(mode="r")

    def callMeo(self):
        messagebox.showinfo(title="Meo's Tkinter Grid oo programming sample", 
		  message="This module was programming by Didier Meo.\nCe module a ?t? programm? par Didier Meo.\n Dieses Modul wurde von Didier Meo programmiert.")

    def btnQuitClick(self):
        self.quit()
        self.master.destroy()

    def AjouterControles(self):
        top=self.winfo_toplevel()
        # top["menu"] = self.menuBar
        top.rowconfigure(0, weight=1, minsize=200)
        top.columnconfigure(0, weight=1, minsize=200)

        self.menuBar = Menu(top)
        self.menu = Menu(self.menuBar)

        self.fileMenu = Menu(self.menu )
        self.menuBar.add_cascade(label="File", menu=self.fileMenu)
        self.fileMenu.add_command(label="New", command=self.callNew)
        self.fileMenu.add_command(label="Open...", command=self.callOpen)
        self.fileMenu.add_separator()
        self.fileMenu.add_command(label="Exit", command=self.btnQuitClick)

        self.subMenu = Menu(self.menu )
        self.menuBar.add_cascade(label="Help", menu=self.subMenu)
        self.subMenu.add_command(label="About", command=self.callMeo)
        top.config(menu=self.menuBar)

        self.btnQuit = Button ( self, text="Quit", command=self.btnQuitClick, width=5, height=2)
        self.btnQuit.grid(row=4, column=5, sticky=N+S+E+W)
        self.lblText1 = Label(self, text="Text 1:", width=8, height=2).grid(row=0, column=0)
        self.etyText1 = Entry(self).grid(row=0, column=1)
        self.rbnRadio1 = Radiobutton(self, text="Radio1:", width=5, height=2).grid(row=1, column=0)
        self.rbnRadio2 = Radiobutton(self, text="Radio2:", width=5, height=2).grid(row=2, column=0)
        self.cbnCheck1 = Checkbutton(self).grid(row=1, column=1)
        self.cbnCheck2 = Checkbutton(self).grid(row=2, column=1)

        self.canvas1 = Canvas(self, width=100, height=190)
        self.canvas1.create_rectangle(10, 10, 90, 180, fill="yellow")
        self.canvas1.grid( row=0, column=5, columnspan=5)

win1 = Fenetre()
win1.master.title("Meo's Tkinter Grid oo programming sample")
win1.mainloop()

	  

Tweet