[Tutor] Explorer bar window(wxpython) combined to Tkinter

Pooja Bhalode poojabhalode11 at gmail.com
Wed Feb 8 18:09:08 EST 2017


Hi,

I have been working on creating an explorer bar in GUI. I found the code
the explorer bar online using wx python. This creates a window shown below.
[image: Inline image 1]

But, I want to create this in the original GUI window that I am working in
using Tkinter. However, when I tried importing it, I am not able to
understand how to deal with different roots,

wxpython:
root = wx.App(False)

Tkinter
root = Tk()

The code for the wxpython is given below:
import os
import wx

class MainWindow(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)

        self.panel = wx.Panel(self)
        self.dir = wx.GenericDirCtrl(self.panel, size=(200, -1),
style=wx.DIRCTRL_DIR_ONLY)
        self.files = wx.ListCtrl(self.panel, style=wx.LC_LIST)

        self.sizer = wx.BoxSizer()
        self.sizer.Add(self.dir, flag=wx.EXPAND)
        self.sizer.Add(self.files, proportion=1, flag=wx.EXPAND)

        self.border = wx.BoxSizer()
        self.border.Add(self.sizer, 1, wx.ALL | wx.EXPAND, 5)

        self.panel.SetSizerAndFit(self.border)
        self.Show()

        self.dir.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelect)


    def OnSelect(self, e):
        self.files.ClearAll()
        list = os.listdir(self.dir.GetPath())
        for a in reversed(list):
            self.files.InsertStringItem(0, a)

root = wx.App(False)

win = MainWindow(None, size=(600, 400))
root.MainLoop()

whereas the code for the GUI that I am working on using Tkinter is given
below:

from Tkinter import *
import datetime
import tkMessageBox
from tkFileDialog import *
from tkMessageBox import *

root = Tk()
root.title("Design of Experiments with Parameter Estimation")
root.geometry("1000x1000")

menu = Menu(root)

root.config(menu=menu)

submenu = Menu(menu)
menu.add_cascade(label="File", menu=submenu)

submenu.add_command(label="New", command=NewWindow)
submenu.add_command(label="Open", command=OpenFile)
submenu.add_command(label="Load", command=LoadNew)
submenu.add_separator()
submenu.add_command(label="Save", command=save)
submenu.add_command(label="Save As", command=Doit)

root.mainloop()

The GUI shows as below:

[image: Inline image 2]


Can someone please tell me how to combine these two so that the
Explorer bar shows up in the space shown in the figure.

Thank you so much in advance.

Yours truly,

Pooja


More information about the Tutor mailing list