0

I'm doing an assignment but need your advise positioning scale in tkinter, I do not have any success, trying multiple options, perhaps you could give me an idea:

The scale should cover full length of my window, but only gets centred Why ?, I will need to add more scales in the near future without change screen dimensions.

Thanks

import Tkinter as tk

from random import randint

from Tkinter import *
class MyApplication(Frame):

    def __init__(self, master):

    Frame.__init__(self, master)    
        self.grid(row=0,column=1)
        self.canvas=tk.Canvas(master, width=400,   
        height=400,background='white')    
        self.canvas.grid(row=0,column=0)
        label = Label(self, text='Count')
        label.grid(row=0,column=2,sticky=(N,S,E,W))
        self.sc1 = Scale(self, variable=1, from_=100, to=1)
        self.sc1.grid(row=1, column=2, rowspan=1,sticky=(N,S,E,W))
        self.sc1.bind("<ButtonRelease-1>")

        button = Button(root,text='Start')
        button1 = Button(root,text='Stop')
        button2 = Button(root,text='Clear')
        button.grid(row=400,sticky=(W))
        button1.grid(row=400,sticky=(N))
        button2.grid(row=400,sticky=(E))

# Main 
root = Tk()
app = MyApplication(root)

root.mainloop()
finefoot
  • 9,914
  • 7
  • 59
  • 102
lmarin
  • 3
  • 2
  • is there a reason you're creating a frame object, but the canvas and some of the buttons are being created as a child of the root window? That's very unusual, and makes your code hard to understand. What's the point of the frame class if it doesn't encapsulate all of the widgets? – Bryan Oakley May 02 '16 at 12:00
  • Yes, I'm creating a control panel, is there a better way of doing ? – lmarin May 02 '16 at 19:44
  • That doesn't answer the question. You made a specific design decision to create a subclass of Frame, which typically serves as a container for other widgets. However, this container creates widgets both in it, and in the root which is a highly unusual thing to do. Is there a specific reason you're doing it that way? Normally the only widgets created by the subclass of a frame are children of the frame, not children of the root. – Bryan Oakley May 02 '16 at 21:23

0 Answers0