Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2c46f7f

Browse filesBrowse files
authored
Merge pull request #5 from CarlosFFM/master
Cambios a la estrucutra de los boxes para el correcto render en Windows (solución temporal, el problema es un bug de toga)
2 parents dfc1a71 + fc4f763 commit 2c46f7f
Copy full SHA for 2c46f7f

15 files changed

+218
-33
lines changed

‎.idea/encodings.xml

Copy file name to clipboardExpand all lines: .idea/encodings.xml
+4Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/misc.xml

Copy file name to clipboardExpand all lines: .idea/misc.xml
+4Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/modules.xml

Copy file name to clipboardExpand all lines: .idea/modules.xml
+8Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/uPy_IDE.iml

Copy file name to clipboardExpand all lines: .idea/uPy_IDE.iml
+11Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/vcs.xml

Copy file name to clipboardExpand all lines: .idea/vcs.xml
+6Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/workspace.xml

Copy file name to clipboardExpand all lines: .idea/workspace.xml
+127Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎README.md

Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ source venv/bin/activate
2626
pip install --pre toga
2727
pip install pyserial
2828
pip install python-dotenv
29+
30+
pip install click
2931
~~~~
3032

3133

176 Bytes
Binary file not shown.
248 Bytes
Binary file not shown.
7.72 KB
Binary file not shown.
10.9 KB
Binary file not shown.
98.8 KB
Binary file not shown.
8.51 KB
Binary file not shown.
10.5 KB
Binary file not shown.

‎uPy_IDE/app.py

Copy file name to clipboardExpand all lines: uPy_IDE/app.py
+56-33Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
import toga
2-
from toga.style import Pack
3-
from toga.constants import COLUMN, ROW
1+
import glob
42
import os
53
import sys
6-
import glob
7-
import serial
84
import time
5+
6+
import serial
7+
import toga
98
import uPy_IDE.esptool as esptool
9+
from toga.constants import COLUMN, ROW
10+
from toga.style.pack import *
11+
12+
# TODO: Exportar un ejecutable de Windows
13+
14+
# Correr en un proceso aparte para que no se congele la UI
15+
def run_in_process(self, button, code_to_run):
16+
import timeit
17+
elapsed_time = timeit.timeit(code_to_run, number=1) # just to save it somewhere
18+
return elapsed_time
19+
1020

1121
def serial_ports():
1222
if sys.platform.startswith('win'):
@@ -55,29 +65,23 @@ def startup(self):
5565
self.commandesp=toga.TextInput(style=Pack(flex=1,width=450))
5666

5767
#intento de terminal
58-
self.textterminal=toga.MultilineTextInput(readonly=False,style=Pack(flex=1,width=600,height=600))
68+
self.textterminal=toga.MultilineTextInput(id='terminal')
5969

6070
#textoutputs
61-
self.textoutputs=toga.MultilineTextInput(readonly=True,style=Pack(flex=1,width=200,height=200))
62-
63-
#botones
64-
self.btnport=toga.Button("Abrir puerto", on_press=self.open_port, style=Pack(padding=2))
71+
self.textoutputs=toga.MultilineTextInput(id='output')
6572

6673

6774
self.filelabel=toga.Label("No ha seleccionado ningun archivo", style=Pack(padding=2))
6875
self.fname=None
69-
self.main_window.content=toga.Box(
70-
children=[
71-
toga.Box(style=box_style_verti, children=[
72-
73-
toga.Box(style=Pack(direction=ROW,padding_left=25), children=[
76+
# definir los hijos del main box afuera del main box
77+
left_box = toga.Box(style=box_style_verti)
78+
left_box.add(toga.Box(style=Pack(direction=ROW,padding_left=25), children=[
7479
self.portselect,
7580
self.chipselect,
7681
self.verselect,
7782
self.switchdio
78-
]),
79-
80-
toga.Box(style=Pack(direction=COLUMN,padding_top=7), children=[
83+
]))
84+
left_box.add(toga.Box(style=Pack(direction=COLUMN,padding_top=7), children=[
8185
toga.Button("Ver archivos en ESP", on_press=self.read_files, style=Pack(padding_top=15,padding_left=2)),
8286
toga.Button("Seleccionar archivo", on_press=self.action_open_file_dialog, style=Pack(padding=2)),
8387
self.filelabel,
@@ -87,27 +91,44 @@ def startup(self):
8791
toga.Button("Borrar archivo de ESP", on_press=self.erase_from_esp, style=Pack(padding=2)),
8892
toga.Button("Obtener archivo de ESP", on_press=self.get_file_esp, style=Pack(padding=2)),
8993
self.textoutputs
90-
])
91-
]),
92-
toga.Box(style=box_style_verti, children=[
93-
toga.Button("Flashear",on_press=self.flash),
94-
toga.Button("Borrar flash/firmware",on_press=self.eraseflash),
95-
toga.Button("Actualizar puertos",on_press=self.update_ports),
96-
self.btnport,
97-
self.textterminal,
98-
99-
toga.Box(style=Pack(direction=ROW,padding_top=7), children=[
94+
]))
95+
96+
# Cambio en la estructura de los boxes para que funcione el rendering de los hijos en Windows, el bug es propio de toga al momento de presentar los boxes
97+
# Agregar hijos de right_box
98+
# right_box = toga.Box(style=box_style_verti)
99+
# right_box.add(toga.Button("Flashear",on_press=self.flash, style=Pack(padding=2)))
100+
# right_box.add(toga.Button("Borrar flash/firmware",on_press=self.eraseflash, style=Pack(padding=2)))
101+
# right_box.add(toga.Button("Actualizar puertos",on_press=self.update_ports, style=Pack(padding=2)))
102+
# right_box.add(toga.Button("Abrir puerto", on_press=self.open_port, style=Pack(padding=2)))
103+
# right_box.add(self.textterminal)
104+
# right_box.add(toga.Box(style=Pack(direction=ROW,padding_top=7), children=[
105+
# self.commandesp,
106+
# toga.Button("Enviar comando", on_press=self.send_command, style=Pack(padding=2))
107+
# ])
108+
# )
109+
110+
left_box.add(toga.Button("Flashear",on_press=self.flash, style=Pack(padding=2)))
111+
left_box.add(toga.Button("Borrar flash/firmware",on_press=self.eraseflash, style=Pack(padding=2)))
112+
left_box.add(toga.Button("Actualizar puertos",on_press=self.update_ports, style=Pack(padding=2)))
113+
left_box.add(toga.Button("Abrir puerto", on_press=self.open_port, style=Pack(padding=2)))
114+
left_box.add(self.textterminal)
115+
left_box.add(toga.Box(style=Pack(direction=ROW,padding_top=7), children=[
100116
self.commandesp,
101117
toga.Button("Enviar comando", on_press=self.send_command, style=Pack(padding=2))
102118
])
119+
)
120+
121+
container = toga.Box()
122+
container.add(left_box)
123+
# container.add(right_box)
103124

104-
])
105-
106-
])
125+
self.main_window.content = container
107126

108127
self.main_window.show()
109128

110-
#metodos para la parte de ampy
129+
130+
# TODO: hacer que los metodos inernos sean multi-procesos
131+
# metodos para la parte de ampy
111132
def read_files(self,button):
112133
from uPy_IDE.pyboard import Pyboard
113134
from uPy_IDE import cli
@@ -163,7 +184,8 @@ def get_file_esp(self,button):
163184
self.textterminal.value=fdata
164185

165186
#======================================SOLO MANEJO DE PUERTO========================================================
166-
187+
188+
167189
def open_port(self,button):
168190
from uPy_IDE.pyboard import Pyboard
169191
if not self.port_open:
@@ -177,6 +199,7 @@ def open_port(self,button):
177199
self.btnport.label="Abrir puerto"
178200
self.port_open=False
179201
self.port.exit_raw_repl()
202+
180203

181204
def send_command(self,button):
182205
if self.port_open:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.