Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove dashed line from my menu UI?

Tags:

python

tkinter

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.

enter image description here

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

like image 882
Avión Avatar asked Jul 29 '13 09:07

Avión


1 Answers

Set tearoff option of fileMenu to False (or 0)

fileMenu = Menu(menubar, tearoff=False)
like image 196
falsetru Avatar answered Sep 27 '22 17:09

falsetru