From d3177525d1e14cf20766e7767d9c9d7ea387b9ea Mon Sep 17 00:00:00 2001 From: antoine Date: Sun, 17 Jul 2016 23:15:18 +0200 Subject: [PATCH] =?UTF-8?q?fin=20fonctionnel=20i3,=20tkinter=20et=20kivy?= =?UTF-8?q?=20avec=20fen=C3=A9tre=20flottante=20pour=20i3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__pycache__/tkinter.cpython-35.pyc | Bin 904 -> 2213 bytes VDMAPI/Display/kivy.kv | 24 +++++++ VDMAPI/Display/kivyDisplay.py | 67 ++++++++++++++++++ VDMAPI/Display/pyside.py | 13 ++++ VDMAPI/Display/tkinter.py | 57 +++++++++++---- VDMAPI/Display/wxpython.py | 18 +++++ VDMAPI/tkinter.ui | 46 ------------ main.py | 15 ++-- 8 files changed, 177 insertions(+), 63 deletions(-) create mode 100644 VDMAPI/Display/kivy.kv create mode 100755 VDMAPI/Display/kivyDisplay.py create mode 100755 VDMAPI/Display/pyside.py create mode 100644 VDMAPI/Display/wxpython.py delete mode 100644 VDMAPI/tkinter.ui diff --git a/VDMAPI/Display/__pycache__/tkinter.cpython-35.pyc b/VDMAPI/Display/__pycache__/tkinter.cpython-35.pyc index 94b0ee7e8c90fd564b7280e99536d139368bdae7..d5c37cfcbd4e72e632747a9a6aed672303db89be 100644 GIT binary patch literal 2213 zcmZuzOK&4Z5U!q=AF<;k3xOaAlfxn`V6zAi2t^Ugu2?N%EyMyV4HDMGGj_(Fhw14g z8?&6UH+~6MeokKzhx`RjeAVO0V>c5|ySl5o`>U$2%GvC8+kgN2=hNFR(LZ$Mu_1qj zxBLY|gpZ(ess5tl=-_*lLlABS+!3qXT_sYg-6 zOmTaYqL#75Vw<8BBR44OP}DUt3>ea?Zm3z3t5}Z2@_zniocHmT-(pZiXGG75hPYoC z!Qyc$XlmCghm=cGxLa8^j6u_k4LTDhKu`Mi!uOLrQT}n1`NhFB9w|S}BY!00P{sbk zpC0*=-5>N@k}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7XycsdP!z5IIhodNuWd(A?8hS6SOO0Y9107?J>z!DCL z1qB0vV89j#Ys5APd&CY12i_()cHkS*IB?(~7@hwRx_2DeLuRZ`7w_*7!hA`2Y_xiY z(LTeJqBfqxjEV?2@sTKYyT`o3%Li{hx~}-o(%UqSg_}?V~_{1<8WZWXz+kaK&l+4IP9?^!0S14WuexV zpGMo@Z%Ll^3b{!dnb%!tJt4JSBoM&Z^t2 zO6uDmpiZ#B-_Ii|AZj-HrmmtdNr@`aAQoL@ZBxXXXso~4kbYKWTFN7`Gr$DwgwNPh zHf7t{xN+R{?-A%RDEdcuh=2?m-+}dxv3baqhfBhzDvP>qLZ*&!qAzqvGaMRMr4@Qa zG%fumz_!Pu@~|`y9jdfKtEDu7lx3ZC1>uR5pS!piR(cBc2pR54kSmIG6#X?mMoVDA mCVoE?x{5@5tXx90M@=Y^DgUD~{)?f4S7btO+l(V4ef$qhO}rNX diff --git a/VDMAPI/Display/kivy.kv b/VDMAPI/Display/kivy.kv new file mode 100644 index 0000000..d1b93a1 --- /dev/null +++ b/VDMAPI/Display/kivy.kv @@ -0,0 +1,24 @@ +#:kivy 1.0 + +: + width: 400 + Button: + id: prev + + size_hint_x: None + width: 100 + + text: '<<' + on_press: root._prevAction() + Label: + text_size: 300, None + id: Message + text: 'no VDM load for the moment' + Button: + id: next + + size_hint_x: None + + width: 100 + text: '>>' + on_press: root._nextAction() \ No newline at end of file diff --git a/VDMAPI/Display/kivyDisplay.py b/VDMAPI/Display/kivyDisplay.py new file mode 100755 index 0000000..78ab59c --- /dev/null +++ b/VDMAPI/Display/kivyDisplay.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +from ..VDM import VDM +import os + +import kivy +import i3 +from kivy.app import App +from kivy.properties import * +from kivy.uix.gridlayout import GridLayout +from kivy.core.window import Window + +from kivy.config import Config +Config.set('graphics', 'width', '600') + +class guiApp(GridLayout): + """ display all vdm into kivy interface """ + + # https://kivy.org/docs/api-kivy.properties.html#kivy.properties.ListProperty + # NumericProperty, StringProperty, ListProperty, ObjectProperty, + # BooleanProperty, BoundedNumericProperty, OptionProperty, ReferenceListProperty, AliasProperty, DictProperty + + indice = NumericProperty(0) + vdm = ListProperty([]) + + def __init__(self, **kwargs): + super(guiApp, self).__init__(**kwargs) + self._keyboard = Window.request_keyboard(self._keyboard_closed, self) + self._keyboard.bind(on_key_down = self._on_keyboard_down) + i3.msg("command", "floating enable") + + self.v = VDM() + self.vdm = self.v.get() + self.render() + + def _nextAction(self): + if self.indice == len(self.vdm)-1: + self.vdm = self.v.get() + self.indice = 0 + else: + self.indice += 1 + self.render() + + def _prevAction(self): + if self.indice > 0: + self.indice -= 1 + self.render() + + def _keyboard_closed(self): + self._keyboard.unbind(on_key_down = self._on_keyboard_down) + self._keyboard = None + + def _on_keyboard_down(self, *args): + if args[1][1] == 'right': + self._nextAction() + + elif args[1][1] == 'left': + self._prevAction() + + def render(self): + print(self.indice) + self.ids["Message"].text = self.vdm[self.indice] + + +class kivyApp(App): + def build(self): + return guiApp(cols=3) diff --git a/VDMAPI/Display/pyside.py b/VDMAPI/Display/pyside.py new file mode 100755 index 0000000..760e267 --- /dev/null +++ b/VDMAPI/Display/pyside.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +import sys +import PySide + +app = QtGui.QApplication(sys.argv) + +hello = QtGui.QLabel("hello Qt") +hello.show() +x, y, w, h = 100, 100, 100, 100 +hello.setGeometry(x, y, w, h) + +sys.exit(app.exec_()) \ No newline at end of file diff --git a/VDMAPI/Display/tkinter.py b/VDMAPI/Display/tkinter.py index 3de8644..0f8d2fe 100644 --- a/VDMAPI/Display/tkinter.py +++ b/VDMAPI/Display/tkinter.py @@ -1,18 +1,51 @@ from ..VDM import VDM - import tkinter as tk -import pygubu -import VDMAPI +import i3 +from tkinter import ttk import os class tkinter: - def __init__(self): - self.root = tk.Tk() - - builder = builder = pygubu.Builder() - uiPath = os.path.join(VDMAPI.__path__[0], './', 'tkinter.ui') - builder.add_from_file(uiPath) - mainwindow = builder.get_object('frame', self.root) + def __init__(self): + """ init vdm object and create GUI """ + self.v = VDM() + self.indice = 0 + self.vdm = self.v.get() - def render(self): - self.root.mainloop() \ No newline at end of file + self.root = tk.Tk() + self.gui(self.root) + + def nextAction(self, event=None): + if self.indice == len(self.vdm)-1: + self.vdm = self.v.get() + self.indice = 0 + else: + self.indice+=1 + self.render() + + def prevAction(self, event=None): + if self.indice > 0: + self.indice-=1 + self.render() + + def gui(self, master): + self.mainwindow = ttk.Frame(master) + self.message = tk.Message(master, text="No VDM load for the moment", width="400") + + self.next = ttk.Button(master, text=">>", command=self.nextAction) + self.prev = ttk.Button(master, text="<<", command=self.prevAction) + self.root.bind('', self.prevAction) + self.root.bind('', self.nextAction) + + self.message.pack(fill="y", side="left", padx="5", pady="5") + self.prev.pack(fill="y", side="left", pady="1") + self.next.pack(fill="y", side="right", pady="1") + + def _floatingDisabler(self): + i3.msg("command", "floating enable") + + def render(self): + print("indice {}".format(self.indice)) + + self.message.configure(text=self.vdm[self.indice]) + self.root.after(1, self._floatingDisabler) + self.root.mainloop() diff --git a/VDMAPI/Display/wxpython.py b/VDMAPI/Display/wxpython.py new file mode 100644 index 0000000..684c194 --- /dev/null +++ b/VDMAPI/Display/wxpython.py @@ -0,0 +1,18 @@ +#!/usr/bin/python + +import wx + +def onButton(event): + print "Button pressed." + +app = wx.App() +frame = wx.Frame(None, -1, 'win.py') +frame.SetDimensions(0,0,200,50) + +panel = wx.Panel(frame, wx.ID_ANY) +button = wx.Button(panel, wx.ID_ANY, 'Test', (10, 10)) +button.Bind(wx.EVT_BUTTON, onButton) + +frame.Show() +frame.Centre() +app.MainLoop() \ No newline at end of file diff --git a/VDMAPI/tkinter.ui b/VDMAPI/tkinter.ui deleted file mode 100644 index e12150f..0000000 --- a/VDMAPI/tkinter.ui +++ /dev/null @@ -1,46 +0,0 @@ - - - - 200 - 200 - - 0 - True - 0 - - - - 3 - << - - 0 - True - 0 - w - - - - - - 3 - >> - - 2 - True - 0 - e - - - - - - No vdm pull for the moment - - 1 - True - 0 - - - - - diff --git a/main.py b/main.py index c31834f..05d0d57 100755 --- a/main.py +++ b/main.py @@ -15,16 +15,21 @@ if __name__ == "__main__": elif displayType == "tkinter": from VDMAPI.Display.tkinter import tkinter as display - elif displayType == "windows": - from VDMAPI.Display.windows import windows as display + elif displayType == "kivy": + from VDMAPI.Display.kivyDisplay import kivyApp as display + d = display() + d.run() + sys.exit() elif displayType == "console": - None + pass else: - print("Error bad display mode accepted value are : i3, tkinter, windows of console") + print("Error bad display mode accepted value are : i3, tkinter, kivy of console") + sys.exit() else: - print("Error too few argument -d need value : i3, tkinter, windows of console") + print("Error too few argument -d need value : i3, tkinter, kivy of console") + sys.exit() d = display() d.render()