How to create a custom GUI for a python program?

后端 未结 5 737

I want to create a GUI for a python program with a custom design, I have a mock-up in Photoshop and I\'m looking for a library that supports theme or any other library that can

相关标签:
5条回答
  • 2021-02-09 00:47

    If you want something like the GitHub GUI, try PyGame. The window.NOFRAME property is available for removing the border.

    0 讨论(0)
  • 2021-02-09 00:49

    I would recommend pyqt4 or pyside. It has the most robust gui development for python. It already comes with a handful of styles like:

    • Windows
    • WindowsXP
    • WindowsVista
    • Motif
    • CDE
    • Plastique
    • Clearlooks

    And you can also create your own styles. This link is a good starting point:

    0 讨论(0)
  • 2021-02-09 00:51

    Custom GUIs with wxPython/wxWidgets

    You are correct that in general wxWidgets aims to provide a native look and feel by usually and by default using standard controls however the option exists not to do so. Install wxPython, in a recent version, then install the Docs & Demos package for the same version, and then run the demo and navigate to the Advanced Generic Widgets tab and you will find just about all of the features you are asking for demonstrated in the AUI demo. It does mention custom close, minimise, etc., the only thing you mention that is not in that one demo is gradient buttons. You will also find demos of gradient & aqua buttons, and a Zoom Bar - a la Mac but platform independent. screenshots of the AUI demo & the demo package on zoom bar are attached:

    wxPython AGW AUI Screenshot:

    wxPython AGW AUI Screenshot

    Demo on Zoom Bar:

    Zoom Bar

    Note on file sizes:

    I have been using wxPython for several years and my current main project provides a huge amount of functionality in 15-20 executables but py2exe gives me a set of distributable files that zip to under 35 Megabytes including documentation & re-distributable libraries - I had one very experienced person come up to me and demand to know where the rest of my deliverable package was hidden - was it on-line or was I pre-installing it in some other way - he was shocked to learn that it was all in the single zip file.

    0 讨论(0)
  • 2021-02-09 00:51

    Qt supports two main ways to customize the look (and feel):

    • Styles:For example Oxygen or the native Styles like the Windows style or the Mac style. Styles are rather complicated to develop as they need to directly interact with the underlying OS. You probably don't want this. Plus I don't think styles can be written in Python, but I may be wrong here.

    • Stylesheets: These are normal CSS stylesheets applied to your GUI. These are very flexible, can be changed at runtime, don't need any other code, can use resources like images and can influence or change most of the rendering.
      This stylesheet for example just scratches the surface of the possible...

    Please note that many users find custom GUI styles disruptive and/or bugging as they normally expect an application to look native, i.e. like all other applications. There are good reasons for custom GUIs, though, for example with imaging software one often wants GUIs with less contrast (like Adobe, Blender, etc. do it) in order to not disturb the image viewed/edited.

    The huge advantage of using a widely used toolkit like Qt or GTK+ and customize it's looks is that usability is mostly preferred, whereas toolkits developed for games or similar usually expose inferior usability.

    0 讨论(0)
  • 2021-02-09 01:07

    Your initial approach with wxPython is fine, you just need a couple more style flags for your top wx.Frame:

    wx.NO_BORDER ^ wx.SYSTEM_MENU ^ wx.MINIMIZE_BOX ^ wx.MAXIMIZE_BOX ^ wx.CLOSE_BOX
    

    Which will not only remove the border but the system menu and min/max/close boxes as well.

    Then paint your gui background directly on the client area of your top frame. See this tutorial: and notice that wx.DeviceContext supports painting bitmaps and gradient fills.

    Now make your custom buttons and have them post wx.CloseEvent, wx.IconizeEvent, and wx.MaximizeEvent events when clicked. Lay them out on your custom frame using either absolute positioning or a Sizer. Done.

    0 讨论(0)
提交回复
热议问题