I have a program running fine on one device (laptop) but when trying to run the same code on another device (workstation), I have an error which does not occur on my laptop.
Setting colors in the .kv file works fine on my laptop but running on my workstation I have this error:
[INFO ] [Logger ] Record log in C:\Users\danrf\.kivy\logs\kivy_20-08-19_103.txt
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.2.0
[INFO ] [Kivy ] v2.0.0rc3, git-20c14b2, 20200615
[INFO ] [Kivy ] Installed at "C:\Users\danrf\AppData\Local\Programs\Python\Python38\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\danrf\AppData\Local\Programs\Python\Python38\python.exe"
[INFO ] [Factory ] 185 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer, img_gif ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.6.0 NVIDIA 452.06'>
[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] [GL ] OpenGL renderer <b'GeForce GTX 980 Ti/PCIe/SSE2'>
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version <b'4.60 NVIDIA'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
Connecting to database...
Connected to database!
Parser: File "C:\Users\danrf\Source\Repos\DRFielding\ProDuck\src\GUI.kv", line 109:
...
107: pos_hint: {"center_x": 0.5, "top": 1}
108: font_size: 20
>> 109: color:"grey"
110:
111:<RegistrationWindow>
...
ValueError: invalid literal for int() with base 16: 'grey'
File "C:\Users\danrf\AppData\Local\Programs\Python\Python38\lib\site-packages\kivy\lang\builder.py", line 705, in _apply_rule
setattr(widget_set, key, value)
File "kivy\weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
File "kivy\properties.pyx", line 498, in kivy.properties.Property.__set__
File "kivy\properties.pyx", line 527, in kivy.properties.Property.set
File "kivy\properties.pyx", line 2009, in kivy.properties.ColorProperty.convert
File "kivy\properties.pyx", line 2029, in kivy.properties.ColorProperty.parse_str
File "C:\Users\danrf\AppData\Local\Programs\Python\Python38\lib\site-packages\kivy\utils.py", line 120, in get_color_from_hex
value = [int(x, 16) / 255.
File "C:\Users\danrf\AppData\Local\Programs\Python\Python38\lib\site-packages\kivy\utils.py", line 120, in <listcomp>
value = [int(x, 16) / 255.
Stack trace:
> File "C:\Users\danrf\source\repos\DRFielding\ProDuck\src\ProDuck.py", line 692, in build
> GUI = Builder.load_file(local_directory + "\\GUI.kv")
> File "C:\Users\danrf\source\repos\DRFielding\ProDuck\src\ProDuck.py", line 696, in <module>
> ProDuck().run()
Loaded '__main__'
Loaded 'kivy.app'
Loaded 'runpy'
I am not sure why this error comes up, both devices have the same install of Kivy, same code etc. and setting colors using the words ("grey") works fine on the first machine. This error is specific to one line, but removing it throws the same error to another instance of setting the color.
Can anyone shed some light?
Edit: Minimal runable example
def build(self):
self.icon = local_directory + "\\LogoTransparent.png"
GUI = Builder.load_file(local_directory + "\\GUI.kv")
return GUI
<LoginWindow>:
name: "Login"
canvas.before:
Color:
rgba: app.color_build
Rectangle:
pos: self.pos
size: self.size
username: username
password: password
image: image
GridLayout:
cols: 3
size: root.width, root.height
padding: 10,10,10,10
RelativeLayout:
size: root.width, root.height
Label:
size_hint: 0.1, 0.1
pos_hint: {"center_x": 0.5, "top": 1}
text: app.version_number
font_size: 15
color:"grey"
ImageButton
id: image
size_hint: 0.72, 0.72
pos_hint: {"center_x": 0.5, "top": 0.45}
source: "LogoTransparent.png"
allow_stretch: True
GridLayout:
cols: 1
Label
text: "ProDuck"
font_size: 50
color:"orange"
Label
text: "Data-Driven Productivity"
color: "grey"
font_size: 20
Label
text: "Username"
color:"grey"
TextInput:
id: username
size_hint:(0.2, None)
height: 50
multiline: False
font_size: 30
write_tab: False
on_text_validate: root.login_press()
Label
text: "Password"
color:"grey"
TextInput:
id: password
size_hint: (0.2, None)
height: 50
multiline: False
password: True
font_size: 30
write_tab: False
on_text_validate: root.login_press()
BoxLayout:
orientation: "horizontal"
spacing: 10
Button
size_hint: (0.5,0.5)
text: "Reset Password"
background_normal: "white"
background_color: (1,0.75,0.0,1.0)
Button
size_hint:(0.5,0.5)
text: "Login"
background_normal: "white"
background_color: (1,0.75,0.0,1.0)
on_press:
root.login_press()
root.ids.password.text = ""
root.ids.username.text = ""
BoxLayout:
orientation: "vertical"
padding: 0,10,0,0
Button:
size_hint: (1,0.6)
text: "Create profile"
background_normal: "white"
background_color: (1,0.75,0.0,1.0)
on_release:
app.root.current = "Reg"
root.manager.transition.direction = "up"
RelativeLayout:
ClockWidget:
size_hint: 0.1, 0.1
pos_hint: {"center_x": 0.5, "top": 1}
font_size: 20
color: "grey"
Try adding:
#:import colormap kivy.utils.colormap
to your kv
file, and change:
color: "grey"
to:
color: colormap["grey"]
without that change, I also get an error on that line. But my code continues to run (it just ignores that error).