Traceback (most recent call last):
File "/home/john/kivy-pos5/main.py", line 18, in <module>
PosApp().run()
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 600, in run
runTouchApp()
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 454, in runTouchApp
EventLoop.window.mainloop()
File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 325, in mainloop
self._mainloop()
File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 292, in _mainloop
self.modifiers):
File "_event.pyx", line 281, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4136)
File "/usr/lib/python2.7/dist-packages/kivy/core/window/__init__.py", line 129, in _on_window_key_down
return self.dispatch('on_key_down', keycode, text, modifiers)
File "_event.pyx", line 281, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4136)
File "/usr/lib/python2.7/dist-packages/kivy/uix/textinput.py", line 1630, in _keyboard_on_key_down
self._key_down(key)
File "/usr/lib/python2.7/dist-packages/kivy/uix/textinput.py", line 1577, in _key_down
self.dispatch('on_text_validate')
File "_event.pyx", line 281, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4136)
File "/home/john/kivy-pos5/pos.kv", line 1, in <module>
#:kivy 1.7.2
File "/home/john/kivy-pos5/invoice.py", line 20, in add_row
self.ids.barcode_input(focus=True)
TypeError: 'weakproxy' object is not callable#:kivy 1.7.2
<Invoice>:
rows:6
today:today
invoice_no:invoice_no
barcode_input: barcode_input
query_result:query_result
purchase: purchase
AdminGrid:
cols:4
AdminBtn:
text: "Admin"
AdminBtn:
text: "Inventory"
AdminBtn:
text: "Reports"
AdminBtn:
text: "Help"
GridLayout:
cols:2
size_hint_y: None
row_force_default: True
row_default_height: 40
height:self.minimum_height
Label:
id: today
size_hint_y: None
text_size: self.size
halign: "left"
height: 40
Label:
id: invoice_no
size_hint_y: None
text_size:self.size
halign:"right"
height:40
BarcodeSearch:
TextInput:
id: barcode_input
multiline: False
on_text_validate: root.add_row()
Label:
id: query_result
HeaderBar:
ScrollView:
scroll_y:0
ScrollBox:
id: purchase
<ScrollBox@GridLayout>:
cols:1
height: self.minimum_height
size_hint:1, None
<BarcodeSearch@GridLayout>:
cols:2
size_hint_y: None
row_force_default: True
row_default_height: 40
height:self.minimum_height
<HeaderBar>:
row_default_height: 40
row_force_default: True
cols: 9
height:self.minimum_height
<AdminGrid@GridLayout>:
size_hint_y: None
row_force_default: True
row_default_height: 40
height:self.minimum_height
<AdminBtn@Button>:
size_hint_y: None
height:40import kivy
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
HEADER_NAMES=["", "Barcode", "Description", "Price", "Vat", "Qty", "Vat Sub.", "Total",""]
LABEL_SIZES = [.04, .16, .30, .10, .04, .06, .13, .15, .04]
class HeaderBar(GridLayout):
def __init__(self, **kwargs):
super(HeaderBar, self).__init__(**kwargs)
for name, size in zip(HEADER_NAMES, LABEL_SIZES):
self.add_widget(Label(text=name, size_hint_x=size))import kivy
kivy.require('1.7.2')
from kivy.uix.gridlayout import GridLayout
from kivy.properties import ObjectProperty
from headerbar import HeaderBar
class Invoice(GridLayout):
today = ObjectProperty(None)
invoice_no = ObjectProperty(None)
barcode_input = ObjectProperty(None)
query_result = ObjectProperty(None)
purchase = ObjectProperty(None)
def __init__(self, **kwargs):
super(Invoice, self).__init__(**kwargs)
def add_row(self):
line = HeaderBar()
self.purchase.add_widget(line)
self.ids.barcode_input(focus=True)
print self.idsimport kivy
kivy.require('1.7.2')
from kivy.uix.gridlayout import GridLayout
from kivy.properties import ObjectProperty
from headerbar import HeaderBar
class Invoice(GridLayout):
today = ObjectProperty(None)
invoice_no = ObjectProperty(None)
barcode_input = ObjectProperty(None)
query_result = ObjectProperty(None)
purchase = ObjectProperty(None)
def __init__(self, **kwargs):
super(Invoice, self).__init__(**kwargs)
def add_row(self):
line = HeaderBar()
self.purchase.add_widget(line)
self.ids.barcode_input(focus=True)
print self.idsimport kivy
kivy.require('1.7.2')
from kivy.app import App
from kivy.config import Config
Config.set("graphics", "width", "1000")
Config.set("graphics", "height", "600")
from kivy.core.window import Window
from invoice import Invoice
class PosApp(App):
def build(self):
return Invoice()
if __name__ == "__main__":
PosApp().run() self.ids.barcode_input.focus=True
Cheers Clock.schedule_once(lambda dt:self.ids.barcode_input.focus=True)
SyntaxError: lambda cannot contain assignmentdef input_focus(self, dt):
self.ids.barcode_input.focus=TrueClock.schedule_once(self.input_focus)
And for that question, I think a few simple rules of thumb will be sufficient.
- If it doesn’t return a value, it isn’t an expression and can’t be put into a lambda.
- If you can imagine it in an assignment statement, on the right-hand side of the equals sign, it is an expression and can be put into a lambda.
def some_cool_func(self, *args, **kwargs):
# Black magic happens here
button1.bind(on_release=lambda btn: self.some_cool_func(1, 2))
button2.bind(on_release=lambda btn: self.some_cool_func(reset=True))
button3.bind(on_release=lambda btn: self.some_cool_func(1, 2, button=btn))