Carlos2312 commited on
Commit
76194fd
·
verified ·
1 Parent(s): 2ff6674

Update multi.py

Browse files
Files changed (1) hide show
  1. multi.py +44 -47
multi.py CHANGED
@@ -1,12 +1,12 @@
1
- from pathlib import Path
2
  from IPython.display import display, HTML, clear_output
3
  from IPython import get_ipython
4
  from ipywidgets import widgets
 
5
  import os
6
 
7
  home = Path.home()
8
  src = home / '.gutris1'
9
- css = src / 'multi.css'
10
  mark = src / 'marking.py'
11
  img = src / 'loading.png'
12
 
@@ -14,60 +14,57 @@ A1111 = src / 'A1111.py'
14
  Forge = src / 'Forge.py'
15
  ComfyUI = src / 'ComfyUI.py'
16
 
17
- os.chdir(home)
18
- src.mkdir(parents=True, exist_ok=True)
 
19
 
20
- x = [
21
- f"curl -sLo {css} https://github.com/gutris1/segsmaker/raw/main/script/multi/multi.css",
22
- f"curl -sLo {img} https://github.com/gutris1/segsmaker/raw/main/script/loading.png",
23
- f"curl -sLo {mark} https://github.com/gutris1/segsmaker/raw/main/script/multi/marking.py",
24
- f"curl -sLo {A1111} https://github.com/gutris1/segsmaker/raw/main/script/multi/A1111.py",
25
- f"curl -sLo {Forge} https://huggingface.co/Carlos2312/asd/resolve/main/Forge.py",
26
- f"curl -sLo {ComfyUI} https://github.com/gutris1/segsmaker/raw/main/script/multi/ComfyUI.py"]
27
-
28
- for y in x:
29
- get_ipython().system(y)
30
 
31
- def dupe_button(desc):
32
- button = widgets.Button(description=desc)
33
- button.add_class("buttons")
34
- return button
35
 
36
- output = widgets.Output()
37
- buttons = [dupe_button(desc) for desc in ['A1111', 'Forge', 'ComfyUI']]
38
- selection_panel = widgets.HBox(buttons, layout=widgets.Layout(
39
- width='500px',
40
- height='100%',
41
- display='flex',
42
- flex_flow='row',
43
- align_items='center',
44
- justify_content='space-between',
45
- padding='20px'))
46
 
47
- selection_panel.add_class("main-panel")
 
48
 
49
- def load_css(css):
50
- with css.open("r") as file:
51
- data = file.read()
 
 
52
 
53
- display(HTML(f"<style>{data}</style>"))
54
 
55
- def selection(b):
56
- selection_panel.close()
57
- clear_output()
 
 
58
 
59
- with output:
60
- if b.description == 'A1111':
61
- get_ipython().magic(f'run {A1111}')
62
 
63
- elif b.description == 'Forge':
64
- get_ipython().magic(f'run {Forge}')
 
 
 
 
 
65
 
66
- elif b.description == 'ComfyUI':
67
- get_ipython().magic(f'run {ComfyUI}')
68
 
69
- load_css(css)
70
- display(selection_panel, output)
 
71
 
72
- for button in buttons:
73
- button.on_click(selection)
 
 
1
  from IPython.display import display, HTML, clear_output
2
  from IPython import get_ipython
3
  from ipywidgets import widgets
4
+ from pathlib import Path
5
  import os
6
 
7
  home = Path.home()
8
  src = home / '.gutris1'
9
+ css_setup = src / 'setup.css'
10
  mark = src / 'marking.py'
11
  img = src / 'loading.png'
12
 
 
14
  Forge = src / 'Forge.py'
15
  ComfyUI = src / 'ComfyUI.py'
16
 
17
+ def load_css():
18
+ with open(css_setup, "r") as file:
19
+ data = file.read()
20
 
21
+ display(HTML(f"<style>{data}</style>"))
 
 
 
 
 
 
 
 
 
22
 
23
+ def selection(btn):
24
+ multi_panel.close()
 
 
25
 
26
+ with output:
27
+ if btn == 'A1111':
28
+ get_ipython().run_line_magic('run', f'{A1111}')
29
+ elif btn == 'Forge':
30
+ get_ipython().run_line_magic('run', f'{Forge}')
31
+ elif btn == 'ComfyUI':
32
+ get_ipython().run_line_magic('run', f'{ComfyUI}')
 
 
 
33
 
34
+ options = ['A1111', 'Forge', 'ComfyUI']
35
+ buttons = []
36
 
37
+ for btn in options:
38
+ button = widgets.Button(description='')
39
+ button.add_class(btn.lower())
40
+ button.on_click(lambda x, btn=btn: selection(btn))
41
+ buttons.append(button)
42
 
43
+ output = widgets.Output()
44
 
45
+ multi_panel = widgets.HBox(
46
+ buttons, layout=widgets.Layout(
47
+ width='600px',
48
+ height='405px'))
49
+ multi_panel.add_class('multi-panel')
50
 
51
+ def multi_widgets():
52
+ if not src.exists():
53
+ src.mkdir(parents=True, exist_ok=True)
54
 
55
+ x = [
56
+ f"curl -sLo {css_setup} https://github.com/gutris1/segsmaker/raw/main/script/multi/setup.css",
57
+ f"curl -sLo {img} https://github.com/gutris1/segsmaker/raw/main/script/loading.png",
58
+ f"curl -sLo {mark} https://github.com/gutris1/segsmaker/raw/main/script/multi/marking.py",
59
+ f"curl -sLo {A1111} https://github.com/gutris1/segsmaker/raw/main/script/multi/A1111.py",
60
+ f"curl -sLo {Forge} https://huggingface.co/Carlos2312/asd/resolve/main/Forge.py",
61
+ f"curl -sLo {ComfyUI} https://github.com/gutris1/segsmaker/raw/main/script/multi/ComfyUI.py"]
62
 
63
+ for y in x:
64
+ get_ipython().system(y)
65
 
66
+ load_css()
67
+ display(multi_panel, output)
68
+ os.chdir(home)
69
 
70
+ multi_widgets()