本文整理汇总了Python中util.profile.getPreference函数的典型用法代码示例。如果您正苦于以下问题:Python getPreference函数的具体用法?Python getPreference怎么用?Python getPreference使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getPreference函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, port=None, baudrate=None):
if port == None:
port = profile.getPreference("serial_port")
if baudrate == None:
baudrate = int(profile.getPreference("serial_baud"))
self.serial = None
if port == "AUTO":
programmer = stk500v2.Stk500v2()
for port in serialList():
try:
print "Connecting to: %s %i" % (port, baudrate)
programmer.connect(port)
programmer.close()
time.sleep(1)
self.serial = Serial(port, baudrate, timeout=2)
break
except ispBase.IspError as (e):
print "Error while connecting to %s %i" % (port, baudrate)
print e
pass
except:
print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0]
programmer.close()
elif port == "VIRTUAL":
self.serial = VirtualPrinter()
else:
try:
self.serial = Serial(port, baudrate, timeout=2)
except:
print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0]
print self.serial
示例2: __init__
def __init__(self, port = None, baudrate = None, callbackObject = None):
if port == None:
port = profile.getPreference('serial_port')
if baudrate == None:
if profile.getPreference('serial_baud') == 'AUTO':
baudrate = 0
else:
baudrate = int(profile.getPreference('serial_baud'))
if callbackObject == None:
callbackObject = MachineComPrintCallback()
self._port = port
self._baudrate = baudrate
self._callback = callbackObject
self._state = self.STATE_NONE
self._serial = None
self._baudrateDetectList = baudrateList()
self._baudrateDetectRetry = 0
self._temp = 0
self._bedTemp = 0
self._targetTemp = 0
self._bedTargetTemp = 0
self._gcodeList = None
self._gcodePos = 0
self._commandQueue = queue.Queue()
self._logQueue = queue.Queue(256)
self._feedRateModifier = {}
self._currentZ = -1
self._heatupWaitStartTime = 0
self._heatupWaitTimeLost = 0.0
self._printStartTime100 = None
self.thread = threading.Thread(target=self._monitor)
self.thread.daemon = True
self.thread.start()
示例3: __init__
def __init__(self, port = None, baudrate = None):
if port == None:
port = profile.getPreference('serial_port')
if baudrate == None:
if profile.getPreference('serial_baud') == 'AUTO':
baudrate = 0
else:
baudrate = int(profile.getPreference('serial_baud'))
self.serial = None
if port == 'AUTO':
programmer = stk500v2.Stk500v2()
for port in serialList():
try:
print "Connecting to: %s" % (port)
programmer.connect(port)
programmer.close()
time.sleep(1)
self.serial = self._openPortWithBaudrate(port, baudrate)
break
except ispBase.IspError as (e):
print "Error while connecting to %s" % (port)
print e
pass
except:
print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0]
programmer.close()
elif port == 'VIRTUAL':
self.serial = VirtualPrinter()
else:
try:
self.serial = self._openPortWithBaudrate(port, baudrate)
except:
print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0]
print self.serial
示例4: __init__
def __init__(self, parent):
super(UltimakerCalibrateStepsPerEPage, self).__init__(parent, "Ultimaker Calibration")
if profile.getPreference('steps_per_e') == '0':
profile.putPreference('steps_per_e', '865.888')
self.AddText("Calibrating the Steps Per E requires some manual actions.")
self.AddText("First remove any filament from your machine.")
self.AddText("Next put in your filament so the tip is aligned with the\ntop of the extruder drive.")
self.AddText("We'll push the filament 100mm")
self.extrudeButton = self.AddButton("Extrude 100mm filament")
self.AddText("Now measure the amount of extruded filament:\n(this can be more or less then 100mm)")
p = wx.Panel(self)
p.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
self.lengthInput = wx.TextCtrl(p, -1, '100')
p.GetSizer().Add(self.lengthInput, 0, wx.RIGHT, 8)
self.saveLengthButton = wx.Button(p, -1, 'Save')
p.GetSizer().Add(self.saveLengthButton, 0)
self.GetSizer().Add(p, 0, wx.LEFT, 5)
self.AddText("This results in the following steps per E:")
self.stepsPerEInput = wx.TextCtrl(self, -1, profile.getPreference('steps_per_e'))
self.GetSizer().Add(self.stepsPerEInput, 0, wx.LEFT, 5)
self.AddText("You can repeat these steps to get better calibration.")
self.AddSeperator()
self.AddText("If you still have filament in your printer which needs\nheat to remove, press the heat up button below:")
self.heatButton = self.AddButton("Heatup for filament removal")
self.saveLengthButton.Bind(wx.EVT_BUTTON, self.OnSaveLengthClick)
self.extrudeButton.Bind(wx.EVT_BUTTON, self.OnExtrudeClick)
self.heatButton.Bind(wx.EVT_BUTTON, self.OnHeatClick)
示例5: OnCopyToSD
def OnCopyToSD(self, e):
for f in self.filenameList:
exportFilename = sliceRun.getExportFilename(f)
filename = os.path.basename(exportFilename)
if profile.getPreference('sdshortnames') == 'True':
filename = sliceRun.getShortFilename(filename)
shutil.copy(exportFilename, os.path.join(profile.getPreference('sdpath'), filename))
示例6: main
def main():
# app = wx.App(False)
if profile.getPreference("machine_type") == "unknown":
configWizard.configWizard()
if profile.getPreference("startMode") == "Simple":
simpleMode.simpleModeWindow()
else:
mainWindow()
示例7: baudrateList
def baudrateList():
ret = [250000, 230400, 115200, 57600, 38400, 19200, 9600]
if profile.getPreference('serial_baud_auto') != '':
prev = int(profile.getPreference('serial_baud_auto'))
if prev in ret:
ret.remove(prev)
ret.insert(0, prev)
return ret
示例8: main
def main():
#app = wx.App(False)
if profile.getPreference('machine_type') == 'unknown':
configWizard.configWizard()
if profile.getPreference('startMode') == 'Simple':
simpleMode.simpleModeWindow()
else:
mainWindow()
示例9: main
def main():
#app = wx.App(False)
if profile.getPreference('wizardDone') == 'False':
configWizard.configWizard()
profile.putPreference("wizardDone", "True")
if profile.getPreference('startMode') == 'Simple':
simpleMode.simpleModeWindow()
else:
mainWindow()
示例10: main
def main():
app = wx.App(False)
if profile.getPreference("wizardDone") == "False":
configWizard.configWizard()
profile.putPreference("wizardDone", "True")
if profile.getPreference("startMode") == "Simple":
simpleMode.simpleModeWindow()
else:
mainWindow()
app.MainLoop()
示例11: OnCustomFirmware
def OnCustomFirmware(self, e):
if profile.getPreference('machine_type') == 'ultimaker':
wx.MessageBox('Warning: Installing a custom firmware does not garantee that you machine will function correctly, and could damage your machine.', 'Firmware update', wx.OK | wx.ICON_EXCLAMATION)
dlg=wx.FileDialog(self, "Open firmware to upload", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX")
if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
if not(os.path.exists(filename)):
return
#For some reason my Ubuntu 10.10 crashes here.
firmwareInstall.InstallFirmware(filename)
示例12: OnSafeRemove
def OnSafeRemove(self):
if platform.system() == "Windows":
cmd = "%s %s>NUL" % (os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'EjectMedia.exe')), profile.getPreference('sdpath'))
elif platform.system() == "Darwin":
cmd = "diskutil eject '%s' > /dev/null 2>&1" % (profile.getPreference('sdpath'))
else:
cmd = "umount '%s' > /dev/null 2>&1" % (profile.getPreference('sdpath'))
if os.system(cmd):
self.GetParent().preview3d.ShowWarningPopup("Safe remove failed.")
else:
self.GetParent().preview3d.ShowWarningPopup("You can now eject the card.")
示例13: getDefaultFirmware
def getDefaultFirmware():
if profile.getPreference('machine_type') == 'ultimaker':
if profile.getPreferenceFloat('extruder_amount') > 1:
return None
if profile.getPreference('has_heated_bed') == 'True':
return None
if sys.platform.startswith('linux'):
return resources.getPathForFirmware("ultimaker_115200.hex")
else:
return resources.getPathForFirmware("ultimaker_250000.hex")
return None
示例14: OnSaveProfile
def OnSaveProfile(self, e):
dlg=wx.FileDialog(self, "Select profile file to save", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
dlg.SetWildcard("ini files (*.ini)|*.ini")
if dlg.ShowModal() == wx.ID_OK:
profileFile = dlg.GetPath()
profile.saveGlobalProfile(profileFile)
dlg.Destroy()
示例15: __init__
def __init__(self, filename = None, port = None):
super(InstallFirmware, self).__init__(parent=None, title="Firmware install", size=(250, 100))
if port == None:
port = profile.getPreference('serial_port')
if filename == None:
filename = getDefaultFirmware()
if filename == None:
wx.MessageBox('Cura does not ship with a default firmware for your machine.', 'Firmware update', wx.OK | wx.ICON_ERROR)
self.Destroy()
return
sizer = wx.BoxSizer(wx.VERTICAL)
self.progressLabel = wx.StaticText(self, -1, 'Reading firmware...')
sizer.Add(self.progressLabel, 0, flag=wx.ALIGN_CENTER)
self.progressGauge = wx.Gauge(self, -1)
sizer.Add(self.progressGauge, 0, flag=wx.EXPAND)
self.okButton = wx.Button(self, -1, 'Ok')
self.okButton.Disable()
self.okButton.Bind(wx.EVT_BUTTON, self.OnOk)
sizer.Add(self.okButton, 0, flag=wx.ALIGN_CENTER)
self.SetSizer(sizer)
self.filename = filename
self.port = port
threading.Thread(target=self.OnRun).start()
self.ShowModal()
self.Destroy()
return