Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
The program is meant to show 7 buttons but only shows the first three. I would appreciate some help, I'm trying to make a catalog program that writes files and text in those files. It works without tkinter, but the buttons arent showing up. I wrote the seven buttons and they worked originally but they have since stopped working. I don't know the problem since this is my first time with tkinter.
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()
root.geometry("500x500")
root.title("Catalog 2020")
button = tk.Button(frame,
text = "Make New File",
command=answer1)
button.pack(side=tk.LEFT)
button2 = tk.Button(frame,
text = "Edit File",
command = answer2)
button2.pack(side=tk.LEFT)
button3 = tk.Button(frame,
text = "Append Data",
command = answer3)
button3.pack(side=tk.LEFT)
button4 = tk.Button(frame,
text = "Read File",
command = answer4)
button4.pack(side=tk.LEFT)
button5 = tk.Button(frame,
text = "Delete File",
command = answer5)
button5.pack(side=tk.LEFT)
button6 = tk.Button(frame,
text = "Tell me a Joke",
command = answer6)
button6.pack(side=tk.LEFT)
buttonquit = tk.Button(frame,
text="QUIT",
fg="red",
command=quit)
buttonquit.pack
root.mainloop()
With root.geometry('500x500') your asking your window to be '500x500' , remove that line to fit all the window with the widgets. Also you forgot to say () with the pack of last button, like buttonquit.pack() or you wont see that button too.
Related
Here is my code
from tkinter import *
root = Tk()
root.geometry('500x500')
btn = Button(root, text = 'Play', height=5,width=30, command = root.destroy)
btn.place(x=140, y=200)
w = Label(root, text ='Lost', font=("Courier", 50), height=4)
w.pack()
root.mainloop()#
The button is meant to say play on it
This is a side effect of several things. What's happening here is that the text in your label is being centered vertically in a box with room for 4 lines. That text has opaque background, so the bottom of text box is sitting over the top of your button and hiding the text. If you remove height=4, you'll see that it works just fine.
The other problem here is mixing the placement tools. You are mixing place and pack, and that is going to cause trouble. You may need to think about the layout issues some more.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 months ago.
Improve this question
from pytube import YouTube
root = Tk()
root.geometry('500x300')
root.resizable(0,0)
root.title("YouTube donwloader")
Label(root,text='YouTube video downloader', font ='arial 20 bold').pack()
link = StringVar()
Label(root,text = 'Paste the link here', font = 'arial 15 bold').place(x=160, y = 60)
link_enter = Entry(root, width=70, textvariable= link).place(x=32, y=90)
def Downloader():
url = YouTube(str(link.get()))
video = url.streams.first()
video.donwload()
Label(root, text = 'Donwload', font = 'arial 15 bold', bg = 'pale viloted red', command = Downloader).place(x=180, y = 150)
root.mainloop
When I run the program, it executes, however don't open any windows. Vs code also doesn't show errors
The problem is you never start the mainloop.
Change the last line to:
root.mainloop()
There are other errors, too. Note that the place() method always returns None.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I would want to create a button with tkinter that when you click it then it changes colour. I konw that I can do it by deleting the button but is there any other possibilitis.
Well, there are a lot of options. You can use many GUI libraries like Kivy, Tkinter. But as i dont know what you are using, i am just gonna make a program in Tkinter.
here is the code -
# importing modules
from tkinter import *
import random
# making a window
root = Tk()
root.geometry("400x400")
# just for decoration or the Background Color
mainframe = Frame(root, bg="#121212", width=400, height=400)
mainframe.pack()
# the function changing color
def color_changing(buttonObject):
# randomizes the color in hexcode
r = lambda: random.randint(0, 255)
color = '#%02X%02X%02X' % (r(), r(), r())
# .config configures an Object in Tkinter
buttonObject.config(bg=color)
# making a button
button = Button(root, width=10, font=('Segoe UI', 32, "bold"), text="Click Me", command=lambda: color_changing(button))
# root in Button() is the place where the button has to be placed
# text, width, font, etc are all attributes
# command is a simple way to call a function
# placing it in a specific location
button.place(relx=0.5, rely=0.5, anchor=CENTER)
# making the window so it does not stop running till it is said to be
root.mainloop()
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I was working on an autoclicker with a gui when I ran into this problem: TypeError: call() got an unexpected keyword argument 'text'
Not sure how to fix it, I've tried everything
Full code: https://codeshare.io/axY39N
Label(window, text="Tan AutoClicker", fg="white", bg="#1589d6", font="none
20", width=30).grid(row=0, column=0)
Label(window, text="Keybind:", fg="white", bg="#1589d6", font="none
10").grid(row=3, column=0)
binding = Entry(window, bg="white", width=10)
binding.grid(row=4, column=0)
Button (window, text="Submit", width=6, height=1,
command=set_keybind).grid(row=5, column=0)
Since you haven't posted the complete stacktrace, I'm guessing this is the issue, in your code you have
from tkinter import *
# ...
from pynput.mouse import Button, Controller
Later on you had
Button (window, text="Submit", width=6, height=1, command=set_keybind).grid(row=5, column=0)
So, I think the Button is actually a pynput.mouse.Button, not tkinter.Button as you expected, and pynput.mouse.Button is confused with the extra arguments (text to be exact).
That's one reason to avoid doing from package import *, apart from the readability misconceptions.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am working with an example file of a Tkinter layout. I keep getting an error that is boggling my mind.
the code worked until I inserted the statements:
area.pack()
area.insert(end, "hello")
then I got the error:
Indentation error: unexpected indentation.
ok, so I commented the two statements out (as shown below), to get what is essentially the exact same code I started with, which worked fine- only to keep getting the same error again. I have played around with it for a few hours now and I simply can't grasp the - im sure- really simple thing that is really triggering this. Any thoughts?
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
ZetCode Tkinter tutorial
In this script, we use the grid
manager to create a more complicated
layout.
author: Jan Bodnar
last modified: December 2010
website: www.zetcode.com
"""
from Tkinter import Tk, Text, BOTH, W, N, E, S
from ttk import Frame, Button, Label, Style
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Windows")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.columnconfigure(1, weight=1)
self.columnconfigure(3, pad=7)
self.rowconfigure(3, weight=1)
self.rowconfigure(5, pad=7)
lbl = Label(self, text="Windows")
lbl.grid(sticky=W, pady=4, padx=5)
area = Text(self)
area.grid(row=1, column=0, columnspan=2, rowspan=4,
padx=5, sticky=E+W+S+N)
#area.pack()
#area.insert(end, "hello")
abtn = Button(self, text="Activate")
abtn.grid(row=1, column=3)
cbtn = Button(self, text="Close")
cbtn.grid(row=2, column=3, pady=4)
hbtn = Button(self, text="Help")
hbtn.grid(row=5, column=0, padx=5)
obtn = Button(self, text="OK")
obtn.grid(row=5, column=3)
def main():
root = Tk()
root.geometry("350x300+300+300")
app = Example(root)
root.mainloop()
if __name__ == '__main__':
main()
You're mixing tabs and spaces. Don't do that :-) 1
For future reference, run the code with python -tt instead of just python2. If you mix tabs and spaces python -tt will yell at you and tell you to fix it rather than giving strange indentation errors.
1Don't do that in any language. It only leads to pain and suffering.
2I believe that this is the default behavior for python3.x.