rendered paste body#!BPY""" Registration info for Blender menus:Name: 'GUI module test'Blender: 244Group: 'Misc'Tooltip: 'GUI module test'"""__author__ = "The NifTools team, http://niftools.sourceforge.net/"__url__ = ("blender", "elysiun", "http://niftools.sourceforge.net/")__version__ = "0.1"__bpydoc__ = """\This script is a work in progress, meant to supply easy to use customizableGUI widgets for the NIF import and export scripts."""import Blenderfrom copy import *class vertical_line: def __init__(self, x, y, length, z = 0, color = (0.0, 0.0, 0.0), thickness = 1): self.x = x self.y = y self.z = z self.length = length self.color = color self.thickness = thickness def draw(self): Blender.BGL.glColor3f( * self.color) Blender.BGL.glRecti(self.x, self.y, self.x + self.thickness, self.y + self.length)class horizontal_line: def __init__(self, x, y, length, z = 0, color = (0.0, 0.0, 0.0), thickness = 1): self.x = x self.y = y self.z = z self.length = length self.color = color self.thickness = thickness def draw(self): Blender.BGL.glColor3f( * self.color) Blender.BGL.glRecti(self.x, self.y, self.x + self.length, self.y + self.thickness)class border: def __init__(self, x, y, width, height, z = 0, color = (0.0, 0.0, 0.0), thickness = 1): self.thickness = thickness self.x = x self.y = y self.z = z self.width = width self.height = height self.color = ((0.0, 0.0, 0.0),(0.0, 0.0, 0.0),(0.0, 0.0, 0.0),(0.0, 0.0, 0.0)) if len(color) == 4: self.color = color elif len(color) == 3: self.color = tuple([copy(color) for dummy in (0,1,2,3)]) t = self.thickness self.left = vertical_line(x - t, y , height + t, z, color[0], t) self.top = horizontal_line(x, y + height, width + t, z, color[1], t) self.right = vertical_line(x + width , y - t, height + t, z, color[2], t) self.bottom = horizontal_line(x - t, y - t, width + t, z, color[3], t) def draw(self): self.left.draw() self.top.draw() self.right.draw() self.bottom.draw()class style: def __init__(self, background = (0.5, 0.5, 0.5), color = (0.0, 0.0, 0.0), border_color = (0.0, 0.0, 0.0), border_thickness = 1): self.background = background self.color = color self.border_color = border_color self.border_thickness = border_thickness class rect_area: def __init__(self, x, y, width, height, z, color = (0.5, 0.5, 0.5)): self.x = x self.y = y self.width = width self.height = height self.z = z self.color = color def draw(self): Blender.BGL.glColor3f(*self.color) Blender.BGL.glRecti(self.x, self.y, self.x + self.width, self.y + self.height) class box: def __init__(self, x, y, width, height, z = 0, style = style()): self.x = x self.y = y self.width = width self.height = height self.z = z self.style = style self.background = rect_area(x, y, width, height, z, style.background) self.border = border(x, y, width, height, z, style.border_color, style.border_thickness) def draw(self): self.background.draw() self.border.draw()class text_box: def __init__(self, x, y, width, height, z = 0, value = "", style = style()): self.x = x self.y = y self.width = width self.height = height self.z = z self.value = value self.style = style def draw(self): self.background = box(self.x, self.y, self.width, self.height, self.z, self.style) self.background.draw() Blender.BGL.glColor3f(*self.style.color) Blender.BGL.glRasterPos2i(self.x + 6, self.y + 6) Blender.Draw.Text(self.value) class button: def __init__(self, x, y, width, height, z = 0, value = "", style = style(), callback): pass _GUI_ELEMENTS = {}_c_grey_d = (0.3, 0.3, 0.3)_c_grey_m = (0.6, 0.6, 0.6)_c_grey_l = (0.9, 0.9, 0.9)_c_black = (0.0, 0.0, 0.0)_c_white = (1.0, 1.0, 1.0)_c_red = (1.0, 0.0, 0.0)_c_green = (0.0, 1.0, 0.0)_c_blue = (0.0, 0.0, 1.0)def gui_draw(): global _GUI_ELEMENTS E = _GUI_ELEMENTS tb_style = style(_c_grey_l, _c_black, (_c_white, _c_white, _c_grey_d, _c_grey_d), 2) events = {} E["test"] = text_box( 50, 50, 200, 20, 0, "testing", events, tb_style) E["test"].draw()def gui_btevent(evt): pass def gui_event(evt, val): if evt == Blender.Draw.ESCKEY: Blender.Draw.Exit() Blender.Draw.Redraw(1) Blender.Draw.Register(gui_draw, gui_event, gui_btevent)