Home > database >  I wanna add a small buttons bar down the note and when i do buttons dont appear why?
I wanna add a small buttons bar down the note and when i do buttons dont appear why?

Time:08-05

am trying to make a notepad app and I wanted to add a small bar at the end with buttons to do custom stuff but when I try to add a button it doesn't appear on the program what did I do wrong?

here is the script

from gc import callbacks
import re
from tkinter import *
from tkinter import ttk
import time
from turtle import right

root = Tk()
root.title('Notepad')
root.iconbitmap('C:/notes.ico')
root.geometry("500x500")

root.tk.call("source", "C:/Users/Hero/Documents/Visual Studio code/My project/azure.tcl")
root.tk.call("set_theme", "dark")

def change_theme():
    if root.tk.call("ttk::style", "theme", "use") == "azure-dark":
        root.tk.call("set_theme", "light")
    else:
        root.tk.call("set_theme", "dark")

style=ttk.Style()
style.theme_use('azure-dark')
style.configure("Vertical.TScrollbar", background="grey", bordercolor="black", arrowcolor="white")

scroll = ttk.Scrollbar(root, orient='vertical')
scroll.pack(side=RIGHT, fill='y')

text=Text(root, font=("Georgia, 24"), yscrollcommand=scroll.set, bg='#292929')
scroll.config(command=text.yview)
text.pack()

#button am talking about
fonts = ttk.Button(root, text='Size and Font', style='Accent.TButton')
fonts.pack()

root.mainloop()

Update: It worked when i had the buttons at the top but at the bottom it doesn't show up

CodePudding user response:

The text box is too tall for a window with size 500x500, so the button below the text box is out of the viewable area of the window.

You can set the width and height options of the text box to a smaller values and use text.pack(fill='both', expand=1)` to expand the text box to fill the window:

# set width and height to smaller values
text = Text(root, font=("Georgia, 24"), yscrollcommand=scroll.set, bg='#292929', width=1, height=1)
# then expand it to fill the window
text.pack(fill='both', expand=1)

CodePudding user response:

i fixed by adding a frame then making it at the bottom then putting the button at this frame thanks everyone that tried to help

  • Related