Skip to content

Commit

Permalink
Merge pull request #43 from houseofsecrets/develop
Browse files Browse the repository at this point in the history
Trying a fix for "Tcl_AsyncDelete" errors
  • Loading branch information
Danamir authored May 3, 2023
2 parents f9f1fea + e8e05b3 commit 44229b7
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions Scripts/SdPaint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
import functools
import gc
import os
import random
import re
Expand Down Expand Up @@ -729,7 +730,6 @@ def select_batch_image(pos):

need_redraw = True
osd(text_time=f"Select batch image seed {batch_image['seed']}")
print(f"Select batch image seed {batch_image['seed']}")

if batch_image.get('image', None):
update_image(batch_image['image'].getbuffer().tobytes())
Expand Down Expand Up @@ -1392,6 +1392,13 @@ def __init__(self, text, title, dialog_width=800, dialog_height=100):
self.dialog_height = dialog_height
super().__init__(None, title=title)

def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.quit()
gc.collect()

def body(self, master):
self.geometry(f'{self.dialog_width}x{self.dialog_height}')

Expand Down Expand Up @@ -1533,13 +1540,13 @@ def apply(self):

elif event.key == pygame.K_n:
if ctrl_down():
dialog = TextDialog(seed, title="Seed", dialog_width=200, dialog_height=30)
if dialog.result and dialog.result.isnumeric():
osd(text=f"Seed: {dialog.result}")
seed = int(dialog.result)
update_config(json_file, write=autosave_seed, values={'seed': seed})
rendering = True
instant_render = True
with TextDialog(seed, title="Seed", dialog_width=200, dialog_height=30) as dialog:
if dialog.result and dialog.result.isnumeric():
osd(text=f"Seed: {dialog.result}")
seed = int(dialog.result)
update_config(json_file, write=autosave_seed, values={'seed': seed})
rendering = True
instant_render = True
else:
rendering = True
instant_render = True
Expand Down Expand Up @@ -1652,21 +1659,21 @@ def apply(self):
instant_render = True
osd(text=f"Dynamic rendering")
elif alt_down():
dialog = TextDialog(negative_prompt, title="Negative prompt")
if dialog.result:
osd(text=f"New negative prompt: {dialog.result}")
negative_prompt = dialog.result
update_config(json_file, write=autosave_negative_prompt, values={'negative_prompt': negative_prompt})
rendering = True
instant_render = True
with TextDialog(negative_prompt, title="Negative prompt") as dialog:
if dialog.result:
osd(text=f"New negative prompt: {dialog.result}")
negative_prompt = dialog.result
update_config(json_file, write=autosave_negative_prompt, values={'negative_prompt': negative_prompt})
rendering = True
instant_render = True
else:
dialog = TextDialog(prompt, title="Prompt")
if dialog.result:
osd(text=f"New prompt: {dialog.result}")
prompt = dialog.result
update_config(json_file, write=autosave_prompt, values={'prompt': prompt})
rendering = True
instant_render = True
with TextDialog(prompt, title="Prompt") as dialog:
if dialog.result:
osd(text=f"New prompt: {dialog.result}")
prompt = dialog.result
update_config(json_file, write=autosave_prompt, values={'prompt': prompt})
rendering = True
instant_render = True

elif event.key == pygame.K_BACKSPACE:
pygame.draw.rect(canvas, (255, 255, 255), (width, 0, width, height))
Expand Down

0 comments on commit 44229b7

Please sign in to comment.