开发者

How do I make a simple file browser in wxPython?

开发者 https://www.devze.com 2022-12-15 07:28 出处:网络
I\'m starting to learn both Python and wxPython and as part of the app I\'m doing, I need to have a simple browser on the left pane of my app开发者_开发技巧. I\'m wondering how do I do it? Or at least

I'm starting to learn both Python and wxPython and as part of the app I'm doing, I need to have a simple browser on the left pane of my app开发者_开发技巧. I'm wondering how do I do it? Or at least point me to the right direction that'll help me more on how to do one. Thanks in advance!

EDIT: a sort of side question, how much of wxPython do I need to learn? Should I use tools like wxGlade?


I think that the GenericDirCtrl widget could be of use for you. This tutorial has many examples, among them a simple usage of that widget in a complete script (screenshot pasted below). And I strongly recommend not to start with wxGlade, but manually layout your first few wx GUIs (with the appropriate sizers). You will learn a lot from this.

How do I make a simple file browser in wxPython?


You can take a look at the wxPython examples, they also include code samples for almost all of the widgets supported by wxPython. If you use Windows they can be found in the Start Menu folder of WxPython.


Sample for wx.html.HtmlWindow

import wx
import wx.html

class MyHtmlFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, -1, title, size=(600,400))
        html = wx.html.HtmlWindow(self)
        wx.CallAfter(html.LoadPage, "http://www.google.com")

app = wx.PySimpleApp()
frm = MyHtmlFrame(None, "Simple HTML Browser")
frm.Show()
app.MainLoop()

wx.HtmlWindow

wx.HtmlWindow is capable of parsing and rendering most simple HTML tags.

It is not intended to be a high-end HTML browser. If you're looking for something like that see the IEHtmlWin class, which wraps the core MSIE HTML viewer.

0

精彩评论

暂无评论...
验证码 换一张
取 消