Skip to content

Commit

Permalink
refatoring and solve bugs disbled buttons and now other options is wo…
Browse files Browse the repository at this point in the history
…rking
  • Loading branch information
Heitor-Tasso committed Mar 15, 2022
1 parent 1163719 commit 0bd4664
Show file tree
Hide file tree
Showing 24 changed files with 110 additions and 130 deletions.
7 changes: 3 additions & 4 deletions components/designer_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from kivy.properties import ObjectProperty, OptionProperty, StringProperty

from functools import partial
import os

SUPPORTED_EXT = ('.py', '.py2', '.kv', '.py3', '.txt', '.diff', )
Expand Down Expand Up @@ -176,7 +175,7 @@ class DesignerContent(FloatLayout):

def __init__(self, **kwargs):
super(DesignerContent, self).__init__(**kwargs)
self.find_tool.bind(on_close=partial(self.show_findmenu, False))
self.find_tool.bind(on_close=lambda *a: self.show_findmenu(False))
self.find_tool.bind(on_next=self.find_tool_next)
self.find_tool.bind(on_prev=self.find_tool_prev)
self.focus_code_input = Clock.create_trigger(self._focus_input)
Expand Down Expand Up @@ -303,7 +302,7 @@ def on_current_tab(self, tabbed_panel, *args):
'''Event handler to tab selection changes
'''
self.show_findmenu(False)
Clock.schedule_once(partial(self._selected_content, tabbed_panel))
Clock.schedule_once(lambda *a: self._selected_content(tabbed_panel))

def _selected_content(self, tabbed_panel, *args):
'''Called after updating tab content
Expand Down Expand Up @@ -431,7 +430,7 @@ def close_tab(*args):
toll_bar_top.popup = popup
return None

Clock.schedule_once(partial(self._perform_close_tab, instance))
Clock.schedule_once(lambda *a: self._perform_close_tab(instance))

def _perform_close_tab(self, tab, *args):
# remove code_input from list
Expand Down
2 changes: 1 addition & 1 deletion components/dialogs/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
height: '15pt'
Label:
text_size: self.size
padding: 30, 20
padding: '30dp', '20dp'
text:" Kivy Designer is Kivy\'s tool for designing Graphical User Interfaces (GUIs) from Kivy Widgets. \\nYou can compose and customize widgets, and test them. It is completely written in Python using Kivy. \\nKivy Designer is integrated with Buildozer and Hanga, so you can easily develop and publish your applications to Desktop and Mobile devices.'"
font_size: pt(12)
valign: 'top'
Expand Down
1 change: 1 addition & 0 deletions components/dialogs/add_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def on_error(self):
def _perform_add_file(self):
'''To copy file from its original path to new path
'''
print('def _perform_add_file -> Adicionando arquivo')
if self.text_file.text == '':
self.lbl_error.text = "Select the File"
return None
Expand Down
7 changes: 2 additions & 5 deletions components/dialogs/new_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
from kivy.properties import ObjectProperty
from kivy.uix.scrollview import ScrollView

from functools import partial


NEW_PROJECTS = {

'FloatLayout': ('template_floatlayout_kv', 'template_floatlayout_py'),
Expand Down Expand Up @@ -230,9 +227,9 @@ def on_cancel(self, *args):
def on_select_button(self, *args):
'''Event Handler for 'on_release' of select button.
'''
self.select_button.bind(on_press=partial(self.dispatch, 'on_select'))
self.select_button.bind(on_press=lambda *a: self.dispatch('on_select'))

def on_cancel_button(self, *args):
'''Event Handler for 'on_release' of cancel button.
'''
self.cancel_button.bind(on_press=partial(self.dispatch, 'on_cancel'))
self.cancel_button.bind(on_press=lambda *a: self.dispatch('on_cancel'))
6 changes: 2 additions & 4 deletions components/dialogs/recent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from uix.listview import ListItemButton
from kivy.lang.builder import Builder

from functools import partial

Builder.load_string("""
#: import hex utils.colors.hex
Expand Down Expand Up @@ -117,12 +115,12 @@ def get_selected_project(self, *args):
def on_select_button(self, *args):
'''Event handler for 'on_release' event of select_button.
'''
self.select_button.bind(on_press=partial(self.dispatch, 'on_select'))
self.select_button.bind(on_press=lambda *a: self.dispatch('on_select'))

def on_cancel_button(self, *args):
'''Event handler for 'on_release' event of cancel_button.
'''
self.cancel_button.bind(on_press=partial(self.dispatch, 'on_cancel'))
self.cancel_button.bind(on_press=lambda *a: self.dispatch('on_cancel'))

def on_select(self, *args):
'''Default event handler for 'on_select' event.
Expand Down
8 changes: 3 additions & 5 deletions components/edit_contextual_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from kivy.properties import ObjectProperty
from kivy.lang.builder import Builder

from functools import partial

Builder.load_string("""
<EditContView>:
Expand Down Expand Up @@ -75,10 +73,10 @@ def show_action_btn_screen(self, show):
if show:
self.action_btn_next_screen = ActionButton(text="Next Screen")
self.action_btn_next_screen.bind(
on_press=partial(self.dispatch, 'on_next_screen'))
on_press=lambda *a: self.dispatch('on_next_screen'))
self.action_btn_prev_screen = ActionButton(text="Previous Screen")
self.action_btn_prev_screen.bind(
on_press=partial(self.dispatch, 'on_prev_screen'))
on_press=lambda *a: self.dispatch('on_prev_screen'))

self.add_widget(self.action_btn_next_screen)
self.add_widget(self.action_btn_prev_screen)
Expand All @@ -88,7 +86,7 @@ def show_find(self, show):
'''
if self.action_btn_find is None:
find = ActionButton(text='Find')
find.bind(on_release=partial(self.dispatch, 'on_find'))
find.bind(on_release=lambda *a: self.dispatch('on_find'))
self.action_btn_find = find

if show:
Expand Down
12 changes: 5 additions & 7 deletions components/kivy_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
)

from pygments.lexers.shell import BashSessionLexer
from functools import partial
import os, sys, subprocess
import _thread as thread
import shlex
Expand Down Expand Up @@ -294,7 +293,7 @@ def clear(self, *args):
self.txtinput_history_box.text = ''
self.textcache = ['']

def _initialize(self, dt):
def _initialize(self, *args):
'''Set console default variable values
'''
self.txtinput_history_box.lexer = BashSessionLexer()
Expand Down Expand Up @@ -327,9 +326,9 @@ def mte(*l):
Clock.schedule_once(mte, -1)

def _focus(self, widg, t_f=True):
Clock.schedule_once(partial(self._deffered_focus, widg, t_f))
Clock.schedule_once(lambda *a: self._deffered_focus(widg, t_f))

def _deffered_focus(self, widg, t_f, dt):
def _deffered_focus(self, widg, t_f):
if widg.get_root_window():
widg.focus = t_f

Expand Down Expand Up @@ -680,7 +679,7 @@ def run_cmd(*args):
popen_stdout_r = popen.stdout.readline
popen_stdout_flush = popen.stdout.flush
txt = popen_stdout_r()
plat = platform()
plat = platform

while txt:
# skip flush on android
Expand Down Expand Up @@ -853,8 +852,7 @@ def read_from_in_pipe(self, *l):
# run command
self.write(txt_line)
else:
Clock.schedule_once(
partial(self.update_cache, txt_line), 0)
Clock.schedule_once(lambda *a: self.update_cache(txt_line), 0)
self.flush()
txt_line = ''

Expand Down
10 changes: 5 additions & 5 deletions components/playground.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
__all__ = ['PlaygroundDragElement', 'Playground']

from matplotlib.pyplot import draw
from core.undo_manager import WidgetDragOperation, WidgetOperation
from uix.confirmation_dialog import ConfirmationDialogSave
from uix.settings import SettingListContent
Expand Down Expand Up @@ -40,7 +39,7 @@
)

import re
import os, io, functools
import os

Builder.load_string("""
Expand Down Expand Up @@ -932,6 +931,8 @@ def remove_widget_from_parent(self, widget, from_undo=False, from_kv=False):
parent = widget.parent
if parent is None and hasattr(widget, 'KD__last_parent'):
parent = widget.KD__last_parent
elif parent is None:
return None

if isinstance(parent.parent, Carousel):
parent.parent.remove_widget(widget)
Expand Down Expand Up @@ -1212,9 +1213,8 @@ def undo_dragging(self):
# some widgets not allow index
self.drag_operation[1].add_widget(self.drag_operation[0])

Clock.schedule_once(functools.partial(
App.get_running_app().focus_widget,
self.drag_operation[0]), 0.01)
focus = App.get_running_app().focus_widget
Clock.schedule_once(lambda *a: focus(self.drag_operation[0]), 0.01)
self.drag_operation = []

def start_widget_dragging(self, *args):
Expand Down
9 changes: 3 additions & 6 deletions components/playground_size_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from kivy.uix.togglebutton import ToggleButton
from kivy.properties import ObjectProperty, OptionProperty, StringProperty

from functools import partial

Builder.load_string("""
<PlaygroundSizeSelector>:
Expand Down Expand Up @@ -86,9 +84,8 @@ def on_press(self):
`~designer.components.playground_size_selector.PlaygroundSizeView`
'''
self.view.size_hint = None, None
self.view.width = self.get_root_window().width / 2.
self.view.height = self.get_root_window().height / 2.
self.view.attach_to = self
self.view.width = self.get_root_window().width / 2.0
self.view.height = self.get_root_window().height / 2.0
self.view.open()

class PlaygroundSizeView(ModalView):
Expand Down Expand Up @@ -190,7 +187,7 @@ def sort_sizes(item):
btntext = f"{name}\n[color=777777][size={int(btn.font_size*0.8)}]{size[0]}x{size[1]}[/size][/color]"
btn.text = btntext

btn.bind(on_press=partial(self.set_size, size))
btn.bind(on_press=lambda *a: self.set_size(size))
grid.add_widget(btn)
self._buttons[name] = btn

Expand Down
4 changes: 1 addition & 3 deletions components/run_contextual_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from kivy.uix.actionbar import ContextualActionView

import webbrowser
from functools import partial


Builder.load_string("""
Expand Down Expand Up @@ -148,7 +146,7 @@ def on_screen_module(self, *args, **kwargs):
def on_webdebugger(self, *args):
'''when running from webdebugger'''
self.dispatch('on_module', mod='webdebugger', data=[])
Clock.schedule_once(partial(webbrowser.open, 'http://localhost:5000/'), 5)
Clock.schedule_once(lambda *a: webbrowser.open('http://localhost:5000/'), 5)

class ModScreenContView(ContextualActionView):

Expand Down
Loading

0 comments on commit 0bd4664

Please sign in to comment.