Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to create canvas and frame in GUI using python?

Description

To create a canvas and frame using python3.

Process

   It is used to draw pictures and other complex layout like graphics, text and widgets.

Frame:

   It acts as a container to hold the widgets. It is used for grouping and organizing the widgets.

Sample Code

Source code(Canvas):

#import tkinter

from tkinter import *

#create root window

top = Tk()

#define canvas variable

w = Canvas(top, bg = “green”,

height = 150, width = 300)

#define coordinates to create arc

coord = 10, 50, 240, 210

oval = w.create_oval(coord,fill = “white”)

line = w.create_line

(10,10,200,200,fill = ‘black’)

w.pack()

top.mainloop()

 

 

Source code(Frame):

#import tkinter

import tkinter as tk

#create root window

top = tk.Tk()

#create GUI frame

frame = Frame(top)

frame.pack()

bottomframe = Frame(top)

bottomframe.pack

( side = BOTTOM )

#buttons

Enggbutton = Button

(frame, text = ‘Engineering’, fg =’red’)

Enggbutton.pack( side = LEFT)

Artsbutton = Button

(frame, text = ‘Arts’, fg=’white’)

Artsbutton.pack( side = LEFT )

Medicalbutton = Button

(frame, text =’Medical’,fg =’green’)

Medicalbutton.pack( side = LEFT )

Diplomabutton = Button

(frame, text =’Diploma’,fg =’black’)

Diplomabutton.pack( side = BOTTOM)

#trigger mainloop

top.mainloop()

Screenshots
create canvas and frame in GUI using python
draw pictures and other complex layout like graphics, text and widgets