Browse Source

fin fonctionnel i3, tkinter et kivy avec fenétre flottante pour i3

master
antoine 5 years ago
parent
commit
d3177525d1
8 changed files with 178 additions and 64 deletions
  1. BIN
      VDMAPI/Display/__pycache__/tkinter.cpython-35.pyc
  2. +24
    -0
      VDMAPI/Display/kivy.kv
  3. +67
    -0
      VDMAPI/Display/kivyDisplay.py
  4. +13
    -0
      VDMAPI/Display/pyside.py
  5. +46
    -13
      VDMAPI/Display/tkinter.py
  6. +18
    -0
      VDMAPI/Display/wxpython.py
  7. +0
    -46
      VDMAPI/tkinter.ui
  8. +10
    -5
      main.py

BIN
VDMAPI/Display/__pycache__/tkinter.cpython-35.pyc View File


+ 24
- 0
VDMAPI/Display/kivy.kv View File

@@ -0,0 +1,24 @@
#:kivy 1.0

<guiApp>:
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()

+ 67
- 0
VDMAPI/Display/kivyDisplay.py View File

@@ -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)

+ 13
- 0
VDMAPI/Display/pyside.py View File

@@ -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_())

+ 46
- 13
VDMAPI/Display/tkinter.py View File

@@ -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 render(self):
self.root.mainloop()
def __init__(self):
""" init vdm object and create GUI """
self.v = VDM()
self.indice = 0
self.vdm = self.v.get()

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('<Left>', self.prevAction)
self.root.bind('<Right>', 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()

+ 18
- 0
VDMAPI/Display/wxpython.py View File

@@ -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()

+ 0
- 46
VDMAPI/tkinter.ui View File

@@ -1,46 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<interface>
<object class="tk.Frame" id="frame">
<property name="height">200</property>
<property name="width">200</property>
<layout>
<property name="column">0</property>
<property name="propagate">True</property>
<property name="row">0</property>
</layout>
<child>
<object class="tk.Button" id="btn_prev">
<property name="height">3</property>
<property name="text" translatable="yes">&lt;&lt;</property>
<layout>
<property name="column">0</property>
<property name="propagate">True</property>
<property name="row">0</property>
<property name="sticky">w</property>
</layout>
</object>
</child>
<child>
<object class="tk.Button" id="btn_next">
<property name="height">3</property>
<property name="text" translatable="yes">&gt;&gt;</property>
<layout>
<property name="column">2</property>
<property name="propagate">True</property>
<property name="row">0</property>
<property name="sticky">e</property>
</layout>
</object>
</child>
<child>
<object class="tk.Message" id="lbl_vdm">
<property name="text" translatable="yes">No vdm pull for the moment</property>
<layout>
<property name="column">1</property>
<property name="propagate">True</property>
<property name="row">0</property>
</layout>
</object>
</child>
</object>
</interface>

+ 10
- 5
main.py View File

@@ -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()

Loading…
Cancel
Save