Best Python code snippet using fMBT_python
phyMdlDspObjGenerator.py
Source:phyMdlDspObjGenerator.py
1######################################################2# File: phyMdlDspObjGenerator.py #3# Author: James Leonard #4# Date: 09/10/2017 #5# Read an input phyMdl file and generate the gendsp #6# patch, for direct import in Max/MSP #7######################################################8def generateHeader():9 return """{10 "patcher" : {11 "fileversion" : 1,12 "appversion" : {13 "major" : 7,14 "minor" : 3,15 "revision" : 1,16 "architecture" : "x64",17 "modernui" : 118 }19,20 "rect" : [ 67.0, 109.0, 700.0, 500.0 ],21 "editing_bgcolor" : [ 0.9, 0.9, 0.9, 1.0 ],22 "bglocked" : 0,23 "openinpresentation" : 0,24 "default_fontsize" : 12.0,25 "default_fontface" : 0,26 "default_fontname" : "Arial",27 "gridonopen" : 1,28 "gridsize" : [ 15.0, 15.0 ],29 "gridsnaponopen" : 1,30 "objectsnaponopen" : 1,31 "statusbarvisible" : 2,32 "toolbarvisible" : 1,33 "lefttoolbarpinned" : 0,34 "toptoolbarpinned" : 0,35 "righttoolbarpinned" : 0,36 "bottomtoolbarpinned" : 0,37 "toolbars_unpinned_last_save" : 0,38 "tallnewobj" : 0,39 "boxanimatetime" : 200,40 "enablehscroll" : 1,41 "enablevscroll" : 1,42 "devicewidth" : 0.0,43 "description" : "",44 "digest" : "",45 "tags" : "",46 "style" : "",47 "subpatcher_template" : "",48 """49def generateNewObjBox(box_Id, nb_In, nb_Out, objName, xPos, yPos):50 boxText = """{ "box" : {51 "id" : " """ + box_Id + """ ",52 "maxclass" : "newobj",53 "numinlets" : """ + str(nb_In) + """,54 "numoutlets" : """ + str(nb_Out) + """,55 "outlettype" : [ "" ],56 "patching_rect" : [ """ + str(yPos) + """, """ + str(xPos) + """, 30.0, 22.0 ],57 "style" : "",58 "text" : " """ + objName + """ "59 } }"""60 return boxText61def generateCodeBox(codeStr, box_Id, nb_In, nb_Out, xPos, yPos):62 boxText = """{ "box" : {63 "code" : " """ + codeStr + """ ",64 "fontface" : 0,65 "fontname" : "Arial",66 "fontsize" : 12.0,67 "id" : " """ + box_Id + """ ",68 "maxclass" : "codebox",69 "numinlets" : """ + str(nb_In) + """,70 "numoutlets" : """ + str(nb_Out) + """,71 "outlettype" : [ "" ],72 "patching_rect" : [ """ + str(yPos) + """, """ + str(xPos) + """, 450.0, 300.0 ],73 "style" : ""74 } }"""75 return boxText76def generatePatchLines(source, srcNb, dest, dstNb):77 text = """ {78 "patchline" : {79 "destination" : [ " """ + dest + """ ", """ + str(dstNb) + """ ],80 "disabled" : 0,81 "hidden" : 0,82 "source" : [ " """ + source + """ ", """ + str(srcNb) + """ ]83 }84 }"""85 return text86def generateDspObj(name, codeboxCode, nbIn, nbOut):87 outFile = open(name, 'w')88 ## GenDSP File Header: always the same89 ## might have to change the 'x64' for 32 bit OS90 outFile.write(generateHeader())91 ## Boxes: codebox + inputs & outputs92 outFile.write('\n "boxes" : [ ')93 ## PhyMdl Codebox94 outFile.write(generateCodeBox(codeboxCode, "phyMdlBox", nbIn, nbOut, 50., 20.))95 outFile.write(', ')96 ## Input objects97 for x in range(1, nbIn + 1):98 outFile.write(generateNewObjBox("inbox_" + str(x), 0, 1, "in " + str(x), 20., 20. + x * 50.))99 outFile.write(', ')100 ## Output objects101 for x in range(1, nbOut):102 outFile.write(generateNewObjBox("outbox_" + str(x), 1, 0, "out " + str(x), 420., 20. + x * 50.))103 outFile.write(', ')104 outFile.write(generateNewObjBox("outbox_" + str(nbOut), 1, 0, "out " + str(nbOut), 420., 20. + nbOut * 50.))105 outFile.write('],\n "lines" : [ ')106 ## Connections107 for x in range(0, nbIn):108 outFile.write(generatePatchLines("inbox_" + str(x + 1), 0, "phyMdlBox", x))109 outFile.write(', ')110 for x in range(0, nbOut - 1):111 outFile.write(generatePatchLines("phyMdlBox", x, "outbox_" + str(x + 1), 0))112 outFile.write(', ')113 outFile.write(generatePatchLines("phyMdlBox", nbOut - 1, "outbox_" + str(nbOut), 0))114 ## End of GenDSP File115 outFile.write('] } } ')116##########################################################...
wkeStruct.py
Source:wkeStruct.py
1from ctypes import (2 c_int,3 c_short,4 c_ushort,5 c_ulong,6 c_long,7 c_longlong,8 c_ulonglong,9 c_float,10 c_char,11 c_char_p,12 c_wchar_p,13 c_bool,14 c_void_p,15 c_size_t,16 Structure,17 byref,18 POINTER,19 create_string_buffer,20 sizeof,21 windll,22 cdll,23 CFUNCTYPE,24 WINFUNCTYPE,25)26from ctypes.wintypes import (27 DWORD,28 HWND,29 INT,30 LONG,31 LPARAM,32 UINT,33 WORD,34 WPARAM,35 RGB,36 MSG,37)38user32 = windll.user3239gdi32 = windll.gdi3240imm32 = windll.imm3241class wkeProxy(Structure):42 _fields_ = [('type', c_int), ('hostname', c_char * 100), ('port',43 c_ushort), ('username', c_char * 50), ('password', c_char * 50)]44class wkeRect(Structure):45 _fields_ = [('x', c_int), ('y', c_int), ('w', c_int), ('h', c_int)]46class wkeMemBuf(Structure):47 _fields_ = [('size', c_int), ('data', c_char_p), ('length', c_size_t)]48class wkeString(Structure):49 pass50class wkePostBodyElement(Structure):51 _fields_ = [('size', c_int), ('type', c_int), ('data', POINTER(wkeMemBuf)),52 ('filePath', wkeString), ('fileStart', c_longlong), ('fileLength', c_longlong)]53class wkePostBodyElements(Structure):54 _fields_ = [('size', c_int), ('element', POINTER(55 POINTER(wkePostBodyElement))), ('elementSize', c_size_t), ('isDirty', c_bool)]56class wkeScreenshotSettings(Structure):57 _fields_ = [('structSize', c_int), ('width', c_int), ('height', c_int)]58class wkeWindowFeatures(Structure):59 _fields_ = [('x', c_int), ('y', c_int), ('width', c_int), ('height', c_int), ('menuBarVisible', c_bool), ('statusBarVisible', c_bool),60 ('toolBarVisible', c_bool), ('locationBarVisible', c_bool), ('scrollbarsVisible', c_bool), ('resizable', c_bool), ('fullscreen', c_bool)]61class wkePrintSettings(Structure):62 _fields_ = [('structSize', c_int), ('dpi', c_int), ('width', c_int), ('height', c_int), ('marginTop', c_int), ('marginBottom', c_int),63 ('marginLeft', c_int), ('marginRight', c_int), ('isPrintPageHeadAndFooter', c_bool), ('isPrintBackgroud', c_bool), ('isLandscape', c_bool)]64class wkePdfDatas(Structure):65 _fields_ = [('count', c_int), ('sizes', c_size_t), ('datas', c_void_p)]66class Rect(Structure):67 _fields_ = [('Left', c_int), ('Top', c_int),68 ('Right', c_int), ('Bottom', c_int)]69class mPos(Structure):70 _fields_ = [('x', c_int), ('y', c_int)]71class mSize(Structure):72 _fields_ = [('cx', c_int), ('cy', c_int)]73class bitMap(Structure):74 _fields_ = [('bmType', c_int), ('bmWidth', c_int), ('bmHeight', c_int), ('bmWidthBytes',75 c_int), ('bmPlanes', c_short), ('bmBitsPixel', c_short), ('bmBits', c_int)]76class blendFunction(Structure):77 _fields_ = [('BlendOp', c_char_p), ('BlendFlags', c_char_p),78 ('SourceConstantAlpha', c_char_p), ('AlphaFormat', c_char_p)]79class PAINTSTRUCT(Structure):80 _fields_ = [('hdc', c_int), ('fErase', c_int), ('rcPaint', Rect), ('fRestore',81 c_int), ('fIncUpdate', c_int), ('hdc', c_int), ('rgbReserved', c_char * 32)]82class COMPOSITIONFORM(Structure):83 _fields_ = [('dwStyle', c_int), ('ptCurrentPos', mPos), ('rcArea', Rect)]84class BITMAPINFOHEADER(Structure):85 """ å
³äºDIBç尺寸åé¢è²æ ¼å¼çä¿¡æ¯ """86 _fields_ = [87 ("biSize", DWORD),88 ("biWidth", LONG),89 ("biHeight", LONG),90 ("biPlanes", WORD),91 ("biBitCount", WORD),92 ("biCompression", DWORD),93 ("biSizeImage", DWORD),94 ("biXPelsPerMeter", LONG),95 ("biYPelsPerMeter", LONG),96 ("biClrUsed", DWORD),97 ("biClrImportant", DWORD),98 ]99class BITMAPINFO(Structure):...
mainwindowpanel.py
Source:mainwindowpanel.py
1# -*- coding: utf-8 -*-2import os3import wx4from . import configelements5from outwiker.core.system import getBuiltinImagePath6from outwiker.gui.guiconfig import MainWindowConfig7from outwiker.gui.controls.formatctrl import FormatCtrl8from outwiker.gui.preferences.baseprefpanel import BasePrefPanel9class MainWindowPanel(BasePrefPanel):10 def __init__(self, parent, application):11 super().__init__(parent)12 self.mainWindowConfig = MainWindowConfig(application.config)13 self._createGUI()14 self.LoadState()15 self.SetupScrolling()16 def _createGUI(self):17 main_sizer = wx.FlexGridSizer(cols=1)18 main_sizer.AddGrowableCol(0)19 self._createTitleFormatGUI(main_sizer)20 self._createStatusbarGUI(main_sizer)21 self.SetSizer(main_sizer)22 def _createStatusbarGUI(self, main_sizer):23 self.statusbarVisibleCheckBox = wx.CheckBox(24 self,25 label=_('Show status panel')26 )27 main_sizer.Add(self.statusbarVisibleCheckBox,28 flag=wx.ALIGN_LEFT | wx.ALL,29 border=2)30 def _createTitleFormatGUI(self, main_sizer):31 """32 СоздаÑÑ ÑлеменÑÑ Ð¸Ð½ÑеÑÑейÑа, ÑвÑзаннÑе Ñ ÑоÑмаÑом заголовка33 главного окна34 """35 hints = [36 ("{file}", _("Wiki file name")),37 ("{page}", _("Page title")),38 ("{subpath}", _("Relative path to current page")),39 ]40 self.titleFormatLabel = wx.StaticText(self,41 -1,42 _("Main window title format"))43 hintBitmap = wx.Bitmap(getBuiltinImagePath("wand.png"))44 self.titleFormatText = FormatCtrl(45 self,46 self.mainWindowConfig.titleFormat.value,47 hints,48 hintBitmap)49 self.titleFormatSizer = wx.FlexGridSizer(1, 2, 0, 0)50 self.titleFormatSizer.Add(self.titleFormatLabel,51 0,52 wx.ALL | wx.ALIGN_CENTER_VERTICAL,53 2)54 self.titleFormatSizer.Add(self.titleFormatText,55 0,56 wx.ALL | wx.EXPAND,57 2)58 self.titleFormatSizer.AddGrowableCol(1)59 main_sizer.Add(self.titleFormatSizer, 1, wx.EXPAND, 0)60 def LoadState(self):61 """62 ÐагÑÑзиÑÑ ÑоÑÑоÑние ÑÑÑаниÑÑ Ð¸Ð· конÑига63 """64 # ФоÑÐ¼Ð°Ñ Ð·Ð°Ð³Ð¾Ð»Ð¾Ð²ÐºÐ° ÑÑÑаниÑÑ65 self.titleFormat = configelements.StringElement(66 self.mainWindowConfig.titleFormat,67 self.titleFormatText68 )69 self.statusbarVisible = configelements.BooleanElement(70 self.mainWindowConfig.statusbar_visible,71 self.statusbarVisibleCheckBox72 )73 def Save(self):74 """75 СоÑ
ÑаниÑÑ ÑоÑÑоÑние ÑÑÑаниÑÑ Ð² конÑиг76 """77 self.titleFormat.save()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!