can I create with Kivy a windowless GUI?

1,040 views
Skip to first unread message

Yaron Elharar

unread,
Oct 7, 2013, 7:54:38 AM10/7/13
to kivy-...@googlegroups.com
Hi everyone

I wanted to ask if it's possible with Kivy and Python to create a windowless GUI that can dock at the right side of the screen,
And will affect other Windows maximum size.

just trying to find out if it's even possible
thanks
Yaron




Gabriel Pettier

unread,
Oct 7, 2013, 10:23:55 AM10/7/13
to kivy-...@googlegroups.com
Hey

That would be platform-dependant i believe, there is an X11 window
provider that should allow that on linux, i believe that's also the
default behavior on Rapsberry pi. But i don't think there are solutions
on windows or OSX currently (and even on linux, the X11 provider may
require some more work to be full-featured). Of course, it's possible to
do such providers for Windows/Osx, it's just a quite more work.

Regards
> --
> You received this message because you are subscribed to the Google Groups "Kivy users support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Paul Sephton

unread,
Oct 7, 2013, 10:35:59 AM10/7/13
to kivy-...@googlegroups.com

On Monday, 7 October 2013 13:54:38 UTC+2, Yaron Elharar wrote:

I wanted to ask if it's possible with Kivy and Python to create a windowless GUI that can dock at the right side of the screen,
And will affect other Windows maximum size.
 
You mean something like the old vista sidebar?  Or like a permanently displayed toolbar?  Perhaps you mean like the Unity toolbar which infringes on screen real estate?

"Windowless GUI" is a bit of an oxymoron here- the X-Window interface always allocates a window as a rectangular part of the screen, and in win32 I know there is always an HWnd.  Some internet references refer to "Windowless GUI" as a gui which consists entirely of top level windows (not child windows).  Others refer to an implementation of a seperate gui implemented within a single OS window (eg. Android on Linux, or Flash UI's in web browser windows). 

I believe that Kivy is always a single OS-provided top level window, which implements it's own touch oriented GUI elements (widgets like buttons, dropdowns, etc) making excellent use of third party API's like OpenGL/ES, gstreamer and PyGame to implement 3d graphics, sound, video, screen transitions, fonts etc. in a completely platform agnostic way.  If it cannot make coffee for you, then it makes up for that little lack in a hundred other wonderful ways.

In other words, if you want to build your own gui inside a single gui window, Kivy already does this, so don't bother.

Paul

Gabriel Pettier

unread,
Oct 7, 2013, 6:52:21 PM10/7/13
to kivy-...@googlegroups.com
I understand it as "borderless and with transparent background", because
it's what makes sense for a dock like program, but maybe i'm wrong.

Paul Sephton

unread,
Oct 8, 2013, 2:10:51 AM10/8/13
to kivy-...@googlegroups.com
On Tuesday, 8 October 2013 00:52:21 UTC+2, tshirtman wrote:
I understand it as "borderless and with transparent background", because
it's what makes sense for a dock like program, but maybe i'm wrong.

Ah- cool. Of course, you are right.

ADEWALE ADISA

unread,
Jun 1, 2014, 3:48:52 PM6/1/14
to kivy-...@googlegroups.com

PiXin Li

unread,
Oct 12, 2014, 11:54:52 AM10/12/14
to kivy-...@googlegroups.com
After hours of googling, I got it work finally...except a little issue.
The window looks on windows 7:

It's a "borderless" window now. I haven't test if transparent works or not, but I think it could be implemented in the same way as borderless, just call win32 api.

The issus is the window cannot move and cannot resize, they should be implemented by user.

The codes:

Require pywin32

import sys
import logging

from kivy.config import Config

def setWindowless():
    """
    Set windowless style
    """
    # This is a platform dependent implementation
    if sys.platform == 'win32':
        from ..External.Win32.Window import (GWL_STYLE, GWL_STYLE_BORDER, GWL_STYLE_CAPTION, GWL_STYLE_THICKFRAME, GWL_STYLE_MINIMIZEBOX, GWL_STYLE_MAXIMIZEBOX, GWL_STYLE_SYSMENU,
            getActiveWindow, getWindowLong, setWindowLong)
        # Get the hwnd of current window and set window long
        hwnd = getActiveWindow()
        if hwnd == 0:
            logging.error('Common.Styles.setWindowless: Failed to get active window hwnd')
            return
        # Here, we must set resizable to false else will cause application appears strange
        # The reason is that when setting GWL_STYLE_BORDER to disabled, the window size will be changed,
        # this may cause the kivy engine to resize the window and thus window style will be reset unexpectly
        Config.set('graphics', 'resizable', 0)
        style = getWindowLong(hwnd, GWL_STYLE)
        style = style & ~(GWL_STYLE_BORDER | GWL_STYLE_CAPTION | GWL_STYLE_THICKFRAME | GWL_STYLE_MINIMIZEBOX | GWL_STYLE_MAXIMIZEBOX | GWL_STYLE_SYSMENU)
        setWindowLong(hwnd, GWL_STYLE, style)
    else:
        logging.error('Common.Styles.setWindowless: Failed to set windowless, unsupported platform [%s]', sys.platform)
        return

And External.Win32.Window

# encoding=utf8
# The window related apis
# Currently this module depends on pywin32:

import logging

try:
    import win32gui
except ImportError:
    logging.error('Require pywin32 lib')
    if __name__ != '__main__':
        raise RuntimeError

# Window api const value definitions

# Window long
GWL_EXSTYLE = -20
GWL_HINSTANCE = -6
GWL_HWNDPARENT = -8
GWL_ID = -12
GWL_STYLE = -16
GWL_USERDATA = -21
GWL_WNDPROC = -4

# window style values
# See:
GWL_STYLE_OVERLAPPED = 0x00000000L
GWL_STYLE_POPUP = 0x80000000L
GWL_STYLE_CHILD = 0x40000000L
GWL_STYLE_MINIMIZE = 0x20000000L
GWL_STYLE_VISIBLE = 0x10000000L
GWL_STYLE_DISABLED = 0x08000000L
GWL_STYLE_CLIPSIBLINGS = 0x04000000L
GWL_STYLE_CLIPCHILDREN = 0x02000000L
GWL_STYLE_MAXIMIZE = 0x01000000L
GWL_STYLE_BORDER = 0x00800000L
GWL_STYLE_DLGFRAME = 0x00400000L
GWL_STYLE_VSCROLL = 0x00200000L
GWL_STYLE_HSCROLL = 0x00100000L
GWL_STYLE_SYSMENU = 0x00080000L
GWL_STYLE_THICKFRAME = 0x00040000L
GWL_STYLE_SIZEBOX = 0x00040000L
GWL_STYLE_GROUP = 0x00020000L
GWL_STYLE_TABSTOP = 0x00010000L

GWL_STYLE_MINIMIZEBOX = 0x00020000L
GWL_STYLE_MAXIMIZEBOX = 0x00010000L

GWL_STYLE_CAPTION = GWL_STYLE_BORDER | GWL_STYLE_DLGFRAME
GWL_STYLE_OVERLAPPEDWINDOW = GWL_STYLE_OVERLAPPED | GWL_STYLE_CAPTION | GWL_STYLE_SYSMENU | GWL_STYLE_THICKFRAME | GWL_STYLE_MINIMIZEBOX | GWL_STYLE_MAXIMIZEBOX
GWL_STYLE_POPUPWINDOW = GWL_STYLE_POPUP | GWL_STYLE_BORDER | GWL_STYLE_SYSMENU
GWL_STYLE_CHILDWINDOW = GWL_STYLE_CHILD

GWL_STYLE_TILED = GWL_STYLE_OVERLAPPED
GWL_STYLE_ICONIC = GWL_STYLE_MINIMIZE
GWL_STYLE_SIZEBOX = GWL_STYLE_THICKFRAME
GWL_STYLE_TILEDWINDOW = GWL_STYLE_OVERLAPPEDWINDOW

def getActiveWindow():
    """
    Get the current active window
    Since kivy only support single window, so this hwnd is the only window hwnd
    """
    return win32gui.GetActiveWindow()

def getWindowLong(hwnd, nIndex):
    """
    Retrieves information about the specified window.
    See:
    """
    return win32gui.GetWindowLong(hwnd, nIndex)

def setWindowLong(hwnd, nIndex, dwNewLong):
    """
    Changes an attribute of the specified window.
    See:
    """
    return win32gui.SetWindowLong(hwnd, nIndex, dwNewLong)



在 2013年10月7日星期一UTC+8下午7时54分38秒,Yaron Elharar写道:
Reply all
Reply to author
Forward
0 new messages