1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00
This commit is contained in:
Shlomi Fish 2017-04-18 23:56:59 +03:00
parent cb646c3155
commit 8e89dd203c
2 changed files with 82 additions and 94 deletions

View file

@ -2,7 +2,7 @@
# -*- mode: python; coding: koi8-r; -*- # -*- mode: python; coding: koi8-r; -*-
import os import os
import gtk, gobject import gtk
imdir = 'images' imdir = 'images'
imtype = 'png' imtype = 'png'
@ -15,6 +15,8 @@ if not os.path.exists(imdir):
os.mkdir(imdir) os.mkdir(imdir)
gc = None gc = None
def draw_rect(): def draw_rect():
global gc global gc
if gc is None: if gc is None:
@ -39,14 +41,15 @@ def save_image(fn, w, h, x=0, y=0):
done = False done = False
def save_callback(*args): def save_callback(*args):
global done global done
if done:
return
if done: return
done = True done = True
print 'create images' print('create images')
style = drawing_area.get_style() style = drawing_area.get_style()
draw_rect() draw_rect()
@ -60,7 +63,6 @@ def save_callback(*args):
drawing_area, "frame", 0, w, 0) drawing_area, "frame", 0, w, 0)
save_image('sep-h', w, 2) save_image('sep-h', w, 2)
# tree # tree
w, h = 32, 32 w, h = 32, 32
w, h = 24, 24 w, h = 24, 24
@ -74,7 +76,6 @@ def save_callback(*args):
None, drawing_area, "stepper", 0, 0, w, h) None, drawing_area, "stepper", 0, 0, w, h)
save_image(fn, w, h) save_image(fn, w, h)
# sizegrip # sizegrip
w, h = 16, 16 w, h = 16, 16
fn = 'sizegrip' fn = 'sizegrip'
@ -83,7 +84,6 @@ def save_callback(*args):
gtk.gdk.WINDOW_EDGE_SOUTH_EAST, 0, 0, w, h) gtk.gdk.WINDOW_EDGE_SOUTH_EAST, 0, 0, w, h)
save_image(fn, w, h) save_image(fn, w, h)
# progress # progress
w, h = 37+3, 16+3 w, h = 37+3, 16+3
progress_style = progress.get_style() progress_style = progress.get_style()
@ -93,7 +93,6 @@ def save_callback(*args):
None, progress, "bar", 0, 0, w, h) None, progress, "bar", 0, 0, w, h)
save_image(fn, w, h) save_image(fn, w, h)
# button # button
w, h = 32, 32 w, h = 32, 32
w, h = 28, 28 w, h = 28, 28
@ -111,7 +110,6 @@ def save_callback(*args):
None, togglebutton, "buttondefault", 0, 0, w, h) None, togglebutton, "buttondefault", 0, 0, w, h)
save_image("button-pa", w, h) save_image("button-pa", w, h)
# toolbar # toolbar
w, h = 16, 16 w, h = 16, 16
w, h = 24, 24 w, h = 24, 24
@ -135,12 +133,11 @@ def save_callback(*args):
None, togglebutton, "buttondefault", 0, 0, w, h) None, togglebutton, "buttondefault", 0, 0, w, h)
save_image("toolbutton-pa", w, h) save_image("toolbutton-pa", w, h)
# slider # slider
msl = hscroll.style_get_property("min_slider_length") msl = hscroll.style_get_property("min_slider_length")
msl = 20 msl = 20
sw = hscroll.style_get_property("slider_width") sw = hscroll.style_get_property("slider_width")
print '>>', msl, sw print('>>', msl, sw)
for t, w, h, state, orient in ( for t, w, h, state, orient in (
('hn', msl, sw, gtk.STATE_NORMAL, gtk.ORIENTATION_HORIZONTAL), ('hn', msl, sw, gtk.STATE_NORMAL, gtk.ORIENTATION_HORIZONTAL),
('ha', msl, sw, gtk.STATE_PRELIGHT, gtk.ORIENTATION_HORIZONTAL), ('ha', msl, sw, gtk.STATE_PRELIGHT, gtk.ORIENTATION_HORIZONTAL),
@ -155,7 +152,8 @@ def save_callback(*args):
fn = 'sbthumb-'+t fn = 'sbthumb-'+t
if 0: if 0:
style.paint_slider(drawing_area.window, state, gtk.SHADOW_OUT, style.paint_slider(drawing_area.window, state, gtk.SHADOW_OUT,
None, drawing_area, "slider", 0,0, w,h, orient) None, drawing_area, "slider",
0, 0, w, h, orient)
else: else:
if orient == gtk.ORIENTATION_VERTICAL: if orient == gtk.ORIENTATION_VERTICAL:
w, h = h, w w, h = h, w
@ -163,7 +161,6 @@ def save_callback(*args):
None, drawing_area, "stepper", 0, 0, w, h) None, drawing_area, "stepper", 0, 0, w, h)
save_image(fn, w, h) save_image(fn, w, h)
msl = hscroll.style_get_property("min_slider_length") msl = hscroll.style_get_property("min_slider_length")
sw = hscroll.style_get_property("slider_width") sw = hscroll.style_get_property("slider_width")
# scale # scale
@ -190,7 +187,6 @@ def save_callback(*args):
None, scale, "trough", 0, 0, w, h) None, scale, "trough", 0, 0, w, h)
save_image(fn, w, h) save_image(fn, w, h)
# arrow # arrow
w = h = hscroll.style_get_property("stepper_size") w = h = hscroll.style_get_property("stepper_size")
# w = h = 15 # w = h = 15
@ -247,7 +243,6 @@ def save_callback(*args):
x+arrow_x, y+arrow_y, arrow_width, arrow_height) x+arrow_x, y+arrow_y, arrow_width, arrow_height)
save_image(fn, w, h, x, y) save_image(fn, w, h, x, y)
# combobox # combobox
w, h = w, 24 w, h = w, 24
w, h = 16, 24 w, h = 16, 24
@ -294,7 +289,6 @@ def save_callback(*args):
None, drawing_area, "entry", 0, 0, w+2, h) None, drawing_area, "entry", 0, 0, w+2, h)
save_image('combo-n', w, h) save_image('combo-n', w, h)
# checkbutton # checkbutton
# define INDICATOR_SIZE 13 # define INDICATOR_SIZE 13
# define INDICATOR_SPACING 2 # define INDICATOR_SPACING 2
@ -311,17 +305,16 @@ def save_callback(*args):
("check-dc", gtk.STATE_INSENSITIVE, gtk.SHADOW_IN), ("check-dc", gtk.STATE_INSENSITIVE, gtk.SHADOW_IN),
("check-du", gtk.STATE_INSENSITIVE, gtk.SHADOW_OUT), ("check-du", gtk.STATE_INSENSITIVE, gtk.SHADOW_OUT),
): ):
## style.paint_flat_box(drawing_area.window, # style.paint_flat_box(drawing_area.window,
## gtk.STATE_PRELIGHT, # gtk.STATE_PRELIGHT,
## gtk.SHADOW_ETCHED_OUT, # gtk.SHADOW_ETCHED_OUT,
## gtk.gdk.Rectangle(0,0,w,h), drawing_area, # gtk.gdk.Rectangle(0, 0,w, h), drawing_area,
## "checkbutton", 0,0, w,h) # "checkbutton", 0, 0, w, h)
style.paint_check(drawing_area.window, state, shadow, style.paint_check(drawing_area.window, state, shadow,
None, drawing_area, "checkbutton", x, y, w, h) None, drawing_area, "checkbutton", x, y, w, h)
save_image(fn, w+2*x, h+2*y) save_image(fn, w+2*x, h+2*y)
# radiobutton # radiobutton
for fn, state, shadow in ( for fn, state, shadow in (
("radio-nc", gtk.STATE_NORMAL, gtk.SHADOW_IN), ("radio-nc", gtk.STATE_NORMAL, gtk.SHADOW_IN),
@ -333,16 +326,15 @@ def save_callback(*args):
("radio-dc", gtk.STATE_INSENSITIVE, gtk.SHADOW_IN), ("radio-dc", gtk.STATE_INSENSITIVE, gtk.SHADOW_IN),
("radio-du", gtk.STATE_INSENSITIVE, gtk.SHADOW_OUT), ("radio-du", gtk.STATE_INSENSITIVE, gtk.SHADOW_OUT),
): ):
## style.paint_flat_box(drawing_area.window, # style.paint_flat_box(drawing_area.window,
## gtk.STATE_PRELIGHT, # gtk.STATE_PRELIGHT,
## gtk.SHADOW_ETCHED_OUT, # gtk.SHADOW_ETCHED_OUT,
## gtk.gdk.Rectangle(0,0,w,h), drawing_area, # gtk.gdk.Rectangle(0, 0,w, h), drawing_area,
## "checkbutton", 0,0, w,h) # "checkbutton", 0, 0, w, h)
style.paint_option(drawing_area.window, state, shadow, style.paint_option(drawing_area.window, state, shadow,
None, drawing_area, "radiobutton", x, y, w, h) None, drawing_area, "radiobutton", x, y, w, h)
save_image(fn, w+2*x, h+2*y) save_image(fn, w+2*x, h+2*y)
# notebook # notebook
w, h = 28, 22 w, h = 28, 22
state = gtk.STATE_NORMAL state = gtk.STATE_NORMAL
@ -352,9 +344,9 @@ def save_callback(*args):
("tab-n", 0, gtk.STATE_NORMAL), ("tab-n", 0, gtk.STATE_NORMAL),
("tab-a", 2, gtk.STATE_ACTIVE), ("tab-a", 2, gtk.STATE_ACTIVE),
): ):
## style.paint_box_gap(drawing_area.window, state, shadow, # style.paint_box_gap(drawing_area.window, state, shadow,
## gtk.gdk.Rectangle(0,0,w,gap_h), drawing_area, # gtk.gdk.Rectangle(0, 0,w,gap_h), drawing_area,
## "notebook", 0,0, w,gap_h, gtk.POS_TOP, 0, w) # "notebook", 0, 0, w,gap_h, gtk.POS_TOP, 0, w)
y = gap_h y = gap_h
hh = h - y hh = h - y
style.paint_extension(drawing_area.window, state, gtk.SHADOW_OUT, style.paint_extension(drawing_area.window, state, gtk.SHADOW_OUT,
@ -362,9 +354,7 @@ def save_callback(*args):
0, y, w, hh, gtk.POS_BOTTOM) 0, y, w, hh, gtk.POS_BOTTOM)
save_image(fn, w, h+2) save_image(fn, w, h+2)
print('done')
print 'done'
gtk.main_quit() gtk.main_quit()
@ -375,6 +365,7 @@ def pack(w, row, col):
gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL,
0, 0) 0, 0)
win = gtk.Window() win = gtk.Window()
win.connect("destroy", gtk.main_quit) win.connect("destroy", gtk.main_quit)
@ -437,6 +428,3 @@ win.show_all()
# drawing_area.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('red')) # drawing_area.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('red'))
gtk.main() gtk.main()

View file

@ -27,7 +27,7 @@ my %skip =
# my $cmd = shell_quote( 'flake8', '.' ); # my $cmd = shell_quote( 'flake8', '.' );
my $cmd = shell_quote( 'flake8', my $cmd = shell_quote( 'flake8',
sort { $a cmp $b } grep { not exists $skip{$_} } glob('./*.py ./scripts/*.py ./tests/board_gen/*.py ./pysollib/*.py ./pysollib/*/{*/*.py,*.py}') ); sort { $a cmp $b } grep { not exists $skip{$_} } glob('./*.py ./data/*/*/*.py ./scripts/*.py ./tests/board_gen/*.py ./pysollib/*.py ./pysollib/*/{*/*.py,*.py}') );
# diag("<$cmd>"); # diag("<$cmd>");