How to remove white lines around application tabs? - python

How to remove white lines around ttk.Notebook Tab window? I want a similar color as the main window.
import tkinter as tk
from tkinter import ttk
win=tk.Tk()
win.geometry("800x600")
win.title("Login and sinup")
canvas=tk.Canvas(win,bg="#303030",width=800,height=600)
canvas.pack()
tabs=ttk.Notebook(canvas)
tabs.pack()
tab1=tk.Frame(tabs,width=650,height=550,bg="#303030")
tabs.add(tab1,text=" New ")
tabs.place(x=100,y=100)
tabs.config()
win.mainloop()

Related

Tkinter (TTK) - How can I change the border color for the TreeView widgets?

I tried to change the default treeview border color using the highlightbackground option but it didn't work (my OS is Windows 10). here is an example:
from tkinter import *
from tkinter import ttk
parent=Tk()
style=ttk.Style()
style.configure("Treeview", highlightbackground="#red") # it doesn't work!!
TreeView = ttk.Treeview(parent)
TreeView.pack()
parent.mainloop()
How can I reach my goal?

Tkinter - How can I remove the background borders from ttk.Button?

by default, the buttons from ttk module, have a one pixel border. how can I delete this border? below an example code:
from tkinter import *
from tkinter import ttk
root = Tk()
root.geometry("400x300")
style=ttk.Style()
style.configure("TButton", padding=0, background="#ffffff") # I colored the background border white to see it in the window.. but, I don't want it, I want to delete the border!
MyButton = ttk.Button(root, text="I have a white border.. how can I delet it?")
MyButton.place(x=16, y=16)
root.mainloop()
I don't want to change the border color in order to hide it in the window,I want to delete it.

How to set scrollText border in tkinter?

I am new to tkinter.
My code likes this,
import tkinter
from tkinter import scrolledtext
Win = tkinter.Tk()
Text = scrolledtext.ScrolledText(Win)
Text.pack(padx=10,pady=10)
Win.mainloop()
As you can see,it only have the left border,top border.
However,it haven't right border and bottom border.
I have watched this How to set border color of certain Tkinter widgets?.
And I have tried highlightbackground=color,
the code is this
import tkinter
from tkinter import scrolledtext
Win = tkinter.Tk()
Text = scrolledtext.ScrolledText(Win)
Text.config(highlightbackground="black")
Text.pack(padx=10,pady=10)
Win.mainloop()
it also didn't work.it made no difference.
In this document:tkinter.scrolledtext — Scrolled Text Widget,I know that the constructor is the same as that of the tkinter.Text class.And I have seen The Tkinter Text Widget,But it didn't have config about the tkinter.Text border.
What should I do?
it only have the left border,top border.
Because the widget config is relief="sunken",
So you can try relief="solid".
So this is may solve your problem
import tkinter
from tkinter import scrolledtext
Win = tkinter.Tk()
Text = scrolledtext.ScrolledText(Win,relief="solid")
Text.pack(padx=10,pady=10)
Win.mainloop()

how to give scroll control with gui in python

i am opening a file in a gui label.
the file i have is big, i need a scroll for it in gui frame.
the code i am using for loading the file and displaying it in a frame is
from Tkinter import *
tk = Tk()
tk.title("Vulnerability Report")
f = open("hola.txt", "r").read()
Label(tk, text=f) .grid(row=0)
tk.mainloop()
Here is the screenshot: I want a scroll here through which i can read the whole file up and down
I have no idea why you are using Canvas instead of Frame and why you are loading a large file on a Label, but you cannot attach a Scrollbar to a label. Tkinter has a ScrolledText widget. Do from tkinter.scrolledtext import ScrolledText and use it as one would a Text widget.

ttk:Entry widget disabled background color

I have a ttk Entry which is in "disabled" state.
The background color of the entry field while disabled is a light blue shade.
How can i change it to the default grey color? From this post i understood how we can change the foreground color.
tkinter ttk Entry widget -disabledforeground
I tried the same method for background color and it did not work.
I am using python 2.7 in Windows 7.
This is the code i tried as per the above said post:
from Tkinter import *
from ttk import *
root=Tk()
style=Style()
style.map("TEntry",background=[("active", "black"), ("disabled", "red")])
entry_var=StringVar()
entry=Entry(root,textvariable=entry_var,state='disabled')
entry.pack()
entry_var.set('test')
root.mainloop()
You don't need to use styles. You can change the color of disabled entry with option disabledbackground=<color>. You can use this option when creating the entry , like:
entry.config(background="black",disabledbackground="red")
So you overall code(Example) is:
from tkinter import *
import time
root=Tk()
entry=Entry(root,state='disabled')
entry.config(background="black",disabledbackground="red")
entry.pack()
root.mainloop()
Here is a screenshot of the GUI:
In ttk and Tk entries widgets, background refers to different things. In Tk Entry, background refers to the color behind the text, in ttk entry, background refers to the color behind the widget. (Yes, I know, confusing right?), what you want to change is fieldbackground. So your code would be
from Tkinter import *
from ttk import *
root=Tk()
style=Style()
style.map("TEntry",fieldbackground=[("active", "black"), ("disabled", "red")])
entry_var=StringVar()
entry=Entry(root,textvariable=entry_var,state='disabled')
entry.pack()
entry_var.set('test')
root.mainloop()

Categories