473,471 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

can not add buttons to 4 frams using tkinter

3 New Member
Can not add button, etc in form. Form has 4 frames and one canvas. Can generate form, but button is not on frame?
---------------------------------------
Expand|Select|Wrap|Line Numbers
  1. from tkinter import *
  2. def Plot():
  3.     root = Tk()
  4.     root.geometry('1340x690+00+00') 
  5.     root.title('Equity bSelection')
  6.     # top border controls
  7.     frame1 = Frame(width=1340, height=200, bg="light  green", colormap="new", borderwidth=0)
  8.     #Button(frame1,text='Plot List', command=sys.exit).pack(side=LEFT)       #command=dispplotlist
  9.     #but1=Button.config(height=3, font=('times',20,'bold')) 
  10.     frame1.pack(side=TOP,padx=0,pady=0)   
  11.  
  12.     # bottom border time scale
  13.     frame2 = Frame(width=1340, height=50, bg="light green", colormap="new", borderwidth=0)
  14.     frame2.pack(side=BOTTOM,padx=0,pady=0)
  15.  
  16.     # left border controls
  17.     frame3 = Frame(width=50, height=450, bg="orange", colormap="new", borderwidth=0)
  18.     frame3.pack(side=LEFT,padx=0,pady=0)
  19.  
  20.     # right border scales for $, and non-$
  21.     frame4 = Frame(width=100, height=450, bg="silver", colormap="new", borderwidth=0)
  22.     frame4.pack(side=RIGHT,padx=0,pady=0)
  23.  
  24.     # charted lines
  25.     canvis1 = Canvas(root, width=1240, height=450, bg='light gray', borderwidth=0)
  26.     canvis1.pack(padx=0,pady=0)
  27. Plot()
  28. mainloop()
---------------------------------------------------
Jan 12 '15 #1
5 1361
bvdet
2,851 Recognized Expert Moderator Specialist
Why create separate frames? Shouldn't root be their parent?
Expand|Select|Wrap|Line Numbers
  1. from Tkinter import *
  2. def Plot():
  3.     root = Tk()
  4.     root.geometry('1340x690+00+00') 
  5.     root.title('Equity bSelection')
  6.     # top border controls
  7.     frame1 = Frame(root, width=1340, height=200, bg="light green", colormap="new", borderwidth=0)
  8.     but1 = Button(frame1,text='Plot List', command=sys.exit)       #command=dispplotlist
  9.     but1.config(height=3, font=('times',20,'bold'))
  10.     but1.pack(side=LEFT)
  11.     frame1.pack(side=TOP,padx=0,pady=0)   
  12.  
  13.     # bottom border time scale
  14.     frame2 = Frame(root, width=1340, height=50, bg="light green", colormap="new", borderwidth=0)
  15.     frame2.pack(side=BOTTOM,padx=0,pady=0)
  16.  
  17.     # left border controls
  18.     frame3 = Frame(root, width=50, height=450, bg="orange", colormap="new", borderwidth=0)
  19.     frame3.pack(side=LEFT,padx=0,pady=0)
  20.  
  21.     # right border scales for $, and non-$
  22.     frame4 = Frame(root, width=100, height=450, bg="medium blue", colormap="new", borderwidth=0)
  23.     frame4.pack(side=RIGHT,padx=0,pady=0)
  24.  
  25.     # charted lines
  26.     canvis1 = Canvas(root, width=1240, height=450, bg='light gray', borderwidth=0)
  27.     canvis1.pack(padx=0,pady=0)
  28. Plot()
  29. mainloop()
Jan 12 '15 #2
jim newbe
3 New Member
For: bvdet

Your posted answer created button on form not on frame!
Expand|Select|Wrap|Line Numbers
  1.     from tkinter import *
  2.     def Plot():
  3.      root = Tk()
  4.      root.geometry('1340x690+00+00')
  5.      root.title('Equity bSelection')
  6.      # top border controls
  7.      frame1 = Frame(root, width=1340, height=50, bg="light green")
  8.  
  9.      but1 = Button(frame1,text='Plot List', command=sys.exit)       #command=dispplotlist
  10.      but1.config(height=3, font=('times',20,'bold'))
  11.      but1.pack(side=LEFT)
  12.      frame1.pack(side=TOP)
  13.  
  14.      # bottom border time scale
  15.      frame2 = Frame(root, width=1340, height=50, bg="light green", colormap="new", borderwidth=0)
  16.      frame2.pack(side=BOTTOM,padx=0,pady=0)
  17.  
  18.      # left border controls
  19.      frame3 = Frame(root, width=50, height=450, bg="orange", colormap="new", borderwidth=0)
  20.      frame3.pack(side=LEFT,padx=0,pady=0)
  21.  
  22.      # right border scales for $, and non-$
  23.      frame4 = Frame(root, width=100, height=450, bg="medium blue", colormap="new", borderwidth=0)
  24.      frame4.pack(side=RIGHT,padx=0,pady=0)
  25.  
  26.      # charted lines
  27.      canvis1 = Canvas(root, width=1240, height=450, bg='light gray', borderwidth=0)
  28.      canvis1.pack(padx=0,pady=0)
  29. Plot()
  30. mainloop()
============================================
Your code work; created button on form and removed frame?
Jan 13 '15 #3
bvdet
2,851 Recognized Expert Moderator Specialist
I don't know what you are trying to do. Do you want a separate top level widget to contain the button?
Jan 13 '15 #4
jim newbe
3 New Member
There is 4 frames top, bottom, left, right, and canvas in center! Top and left frame will contain buttons, select lists etc. to control plot on canvas. Right frame will contain printed scales for $ amount and other units of measure.
Bottom frame will contain time scales, day, week etc.
Canvas well contain plot of equities and stock indicators.
The reason I want separate frames is to control vertical, and horizontal placement of controls with pack on each frame.
there well be no controls on canvas; only drawing of lines with colors and other attributes. I need 4 frames to control packing for each.

In my code the button seems to be on form and not on frame1; the green color is missing!
Jan 14 '15 #5
bvdet
2,851 Recognized Expert Moderator Specialist
You could arrange your frames and canvas on one top level window. I don't get it.
Jan 14 '15 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Stephen M. Gava | last post by:
Hi all, I prefer using tkinter to wxpython (so sue me :) and i need to display a lot of html in a particular app. does anyone know if one of the existing add on tk html widgets have been wrapped...
1
by: Ankit | last post by:
Hi guys i need to make a table to store a certain data using Tkinter..I have searched on the group but i have not been able to find a solution that would work for me..The thing is that i want my...
1
by: psbasha | last post by:
Hi, Is it possible to create a simple viewer using Tkinter Modueles?. If not ,is it possible thru Python and OpenGL or anyother ways of creating a simple viewer?. I would like to have the...
1
by: alivip | last post by:
I integrat program to be GUI using Tkinter I try browser direction as you can see # a look at the Tkinter Text widget # use ctrl+c to copy, ctrl+x to cut selected text, # ctrl+v to...
11
by: Kenneth McDonald | last post by:
Any guesses as to how many people are still using Tkinter? And can anyone direct me to good, current docs for Tkinter? Thanks, Ken
0
by: Guilherme Polo | last post by:
2008/5/10 Kenneth McDonald <kenneth.m.mcdonald@sbcglobal.net>: I will say no to the first question. Now about the second question.. there are these links you may find interesting: "An...
1
by: viv1tyagi | last post by:
Hi everyone ! ! ! I'm just a month old in the world of Python and trying to develop an application using Tkinter in which a new window pops out on a particular button press.The code for this new...
3
by: J-Burns | last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in programming itself... :P. Need some help here. Problem 1: How do I make something appear on 2 separate windows using Tkinter? By...
2
by: mcfly | last post by:
I can apply my python code using import tkinter within the python shell and it works perfectly (i open some file using tkinter). however, when i try to run the file.py from the command prompt...
1
by: sthirumgn | last post by:
how to give coding to radio buttons while using for gender
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.