Added py3 fixes to win32 and Gtk backends.
This commit is contained in:
parent
c6775cb1cf
commit
8a7b7fd723
20 changed files with 58 additions and 18 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
# Examples of valid version strings
|
||||
# NUM_VERSION = (0, 1, 3, 'dev')
|
||||
# NUM_VERSION = (0, 1, 3, ('a', 1))
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
import sys
|
||||
|
||||
from gi.repository import Gtk, Gio, GLib
|
||||
|
|
@ -12,7 +14,7 @@ class MainWindow(Window):
|
|||
class App(object):
|
||||
|
||||
def __init__(self, name, app_id):
|
||||
GLib.set_application_name(name)
|
||||
# GLib.set_application_name(name.encode('ascii'))
|
||||
self._impl = Gtk.Application(application_id=app_id, flags=Gio.ApplicationFlags.FLAGS_NONE)
|
||||
|
||||
self.main_window = MainWindow(self)
|
||||
|
|
@ -22,7 +24,6 @@ class App(object):
|
|||
self._impl.connect('shutdown', self._shutdown)
|
||||
|
||||
def _startup(self, data=None):
|
||||
print "STARTUP"
|
||||
self._impl.add_window(self.main_window._impl)
|
||||
|
||||
action = Gio.SimpleAction.new('stuff', None)
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from .button import Button
|
||||
from .container import Container
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from toga.cassowary.widget import Widget as CassowaryWidget
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .base import Widget
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from gi.repository import Gtk, cairo
|
||||
|
||||
from toga.cassowary.widget import Container as CassowaryContainer
|
||||
|
||||
|
||||
class TContainer(Gtk.Fixed):
|
||||
class GtkContainer(Gtk.Fixed):
|
||||
def __init__(self, layout_manager):
|
||||
super(TContainer, self).__init__()
|
||||
super(GtkContainer, self).__init__()
|
||||
self.layout_manager = layout_manager
|
||||
|
||||
def do_get_preferred_width(self):
|
||||
|
|
@ -29,9 +31,9 @@ class TContainer(Gtk.Fixed):
|
|||
with self.layout_manager.layout(allocation.width, allocation.height):
|
||||
|
||||
for widget in self.layout_manager.children:
|
||||
print widget, widget._bounding_box
|
||||
print(widget, widget._bounding_box)
|
||||
if not widget._impl.get_visible():
|
||||
print "CHILD NOT VISIBLE"
|
||||
print("CHILD NOT VISIBLE")
|
||||
else:
|
||||
min_width, preferred_width = widget._width_hint
|
||||
min_height, preferred_height = widget._height_hint
|
||||
|
|
@ -62,7 +64,7 @@ class TContainer(Gtk.Fixed):
|
|||
class Container(CassowaryContainer):
|
||||
def __init__(self):
|
||||
super(Container, self).__init__()
|
||||
self._impl = TContainer(self._layout_manager)
|
||||
self._impl = GtkContainer(self._layout_manager)
|
||||
|
||||
def add(self, widget):
|
||||
self._impl.add(widget._impl)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
import ctypes
|
||||
|
||||
from .libs import *
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
# Most of this file is win32con.py from Python for Windows Extensions:
|
||||
# http://www.python.net/crew/mhammond/win32/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from ctypes import *
|
||||
from . import constants
|
||||
|
||||
|
||||
_debug_win32 = True
|
||||
|
||||
if _debug_win32:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from .debug import DebugLibrary
|
||||
from .types import *
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from .debug import DebugLibrary
|
||||
from .types import *
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from ..window import key
|
||||
from .constants import *
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from ctypes import *
|
||||
from ctypes.wintypes import *
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
import struct
|
||||
|
||||
from .debug import DebugLibrary
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from .button import Button
|
||||
from .container import Container
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from toga.cassowary.widget import Widget as CassowaryWidget
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from toga.platform.win32.libs import *
|
||||
|
||||
from .base import Widget
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from toga.cassowary.widget import Container as CassowaryContainer
|
||||
|
||||
|
||||
|
|
@ -60,11 +62,11 @@ class Container(CassowaryContainer):
|
|||
@property
|
||||
def _width_hint(self):
|
||||
width = self._layout_manager.bounding_box.width.value
|
||||
print "PREFERRED WIDTH", width
|
||||
print("PREFERRED WIDTH", width)
|
||||
return width, width
|
||||
|
||||
@property
|
||||
def _height_hint(self):
|
||||
height = self._layout_manager.bounding_box.height.value
|
||||
print "PREFERRED HEIGHT", height
|
||||
print("PREFERRED HEIGHT", height)
|
||||
return height, height
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function, unicode_literals, absolute_import, division
|
||||
|
||||
from toga.platform.win32.libs import *
|
||||
|
||||
import ctypes
|
||||
|
|
@ -35,14 +37,14 @@ class Window(object):
|
|||
self._window_class.hInstance,
|
||||
0)
|
||||
|
||||
print 1,self._impl
|
||||
print(1,self._impl)
|
||||
# user32.SetWindowPos(self._impl, HWND_NOTOPMOST,
|
||||
# position[0], position[1], size[0], size[1], SWP_NOMOVE | SWP_FRAMECHANGED)
|
||||
|
||||
ctypes.windll.UxTheme.SetWindowTheme(self._impl, c_wchar_p('Explorer'), 0)
|
||||
|
||||
user32.SetWindowTextW(self._impl, c_wchar_p("Hello World"))
|
||||
print 2,self._impl
|
||||
print(2,self._impl)
|
||||
|
||||
@property
|
||||
def content(self):
|
||||
|
|
@ -59,9 +61,9 @@ class Window(object):
|
|||
widget._create(self, 0, 0, preferred_width, preferred_height)
|
||||
|
||||
def show(self):
|
||||
print 3,self._impl
|
||||
print(3,self._impl)
|
||||
user32.ShowWindow(self._impl, SW_SHOWDEFAULT)
|
||||
print 4,self._impl
|
||||
print(4,self._impl)
|
||||
|
||||
def _allocate_id(self):
|
||||
self._allocated = self._allocated + 1
|
||||
|
|
@ -85,7 +87,7 @@ class Window(object):
|
|||
return result
|
||||
|
||||
def _wm_command(self, msg, wParam, lParam):
|
||||
print "COMMAND RECEIVED", wParam
|
||||
print("COMMAND RECEIVED", wParam)
|
||||
try:
|
||||
widget = self._widgets[wParam]
|
||||
if widget.on_press:
|
||||
|
|
@ -96,10 +98,10 @@ class Window(object):
|
|||
return 0
|
||||
|
||||
def _wm_size(self, msg, wParam, lParam):
|
||||
print "RESIZE"
|
||||
print("RESIZE")
|
||||
width = LOWORD(lParam)
|
||||
height = HIWORD(lParam)
|
||||
print "REQUESTED SIZE", width, height
|
||||
print("REQUESTED SIZE", width, height)
|
||||
if self._content:
|
||||
self._content._resize(0, 0, width, height)
|
||||
return 0
|
||||
|
|
@ -109,12 +111,12 @@ class Window(object):
|
|||
return 0
|
||||
|
||||
def _wm_getminmaxinfo(self, msg, wParam, lParam):
|
||||
print "REQUEST FOR MIN MAX INFO"
|
||||
print("REQUEST FOR MIN MAX INFO")
|
||||
info = MINMAXINFO.from_address(lParam)
|
||||
if self._content:
|
||||
min_width, preferred_width = self.content._width_hint
|
||||
min_height, preferred_height = self.content._height_hint
|
||||
print "SET MIN to %sx%s" % (min_width, min_height)
|
||||
print("SET MIN to %sx%s" % (min_width, min_height))
|
||||
info.ptMinTrackSize.x = int(min_width)
|
||||
info.ptMinTrackSize.y = int(min_height)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue