I'm trying to add a "Open file" file tab on my UI. Works ok, but a ---------
line is showing up at the top of the tab and I want to remove it. I don't know why that line is showing up and I can't find the line on the code.
This is my code:
# -*- coding: utf-8 -*-
from Tkinter import *
import Image
import ImageTk
import tkFileDialog
class Planificador(Frame):
def __init__(self,master):
Frame.__init__(self, master)
self.master = master
self.initUI()
def initUI(self):
self.master.title("test")
menubar = Menu(self.master, tearoff=0)
self.master.config(menu=menubar)
fileMenu = Menu(menubar)
fileMenu.add_command(label="Open config file", command=self.onOpen)
menubar.add_cascade(label="File", menu=fileMenu)
fileMenu.add_separator()
fileMenu.add_command(label="Exit", command=root.quit)
self.txt = Text(self)
self.txt.pack(fill=BOTH, expand=1)
def onOpen(self):
ftypes = [('Python files', '*.py'), ('All files', '*')]
dlg = tkFileDialog.Open(self, filetypes = ftypes)
fl = dlg.show()
if fl != '':
text = self.readFile(fl)
self.txt.insert(END, text)
def readFile(self, filename):
f = open(filename, "r")
text = f.read()
return text
# Main
if __name__ == "__main__":
# create interfacE
root = Tk()
aplicacion = Planificador(root)
root.mainloop()
I would like to know where I can remove that -------
from the code.
Thanks in advance
Set tearoff
option of fileMenu
to False
(or 0
)
fileMenu = Menu(menubar, tearoff=False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With