rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.interact2(a1, a2, d, r, p1, ksi[Z2]) def interact1(self, a1, a2, d, r, p, ksi): x = exp(acut * (r - p['rc']))
if self.fix_alloys: p2 = self.par[Z2] else: p2 = p1 self.interact2(a1, a2, d, r, p1, p2, ksi[Z2]) def interact1(self, a1, a2, d, r, p1, p2, ksi): x = exp(self.acut * (r - self.rc))
def calculate(self, atoms): self.positions = atoms.get_positions().copy() self.cell = atoms.get_cell().copy() self.pbc = atoms.get_pbc().copy() icell = np.linalg.inv(self.cell) scaled = np.dot(self.positions, icell) N = [] for i in range(3): if self.pbc[i]: scaled[:, i] %= 1.0 v = icell[:, i] h = 1 / sqrt(np.dot(v, v)...
y = (0.5 * p['V0'] * exp(-p['kappa'] * (r / beta - p['s0'])) * ksi / p['gamma2'] * theta)
y = (0.5 * p1['V0'] * exp(-p2['kappa'] * (r / beta - p2['s0'])) * ksi / p1['gamma2'] * theta)
def interact1(self, a1, a2, d, r, p, ksi): x = exp(acut * (r - p['rc'])) theta = 1.0 / (1.0 + x) y = (0.5 * p['V0'] * exp(-p['kappa'] * (r / beta - p['s0'])) * ksi / p['gamma2'] * theta) self.energy -= y f = y * (p['kappa'] / beta + acut * theta * x) * d / r self.forces[a1] += f self.forces[a2] -= f self.sigma1[a1] += ...
f = y * (p['kappa'] / beta + acut * theta * x) * d / r
f = y * (p2['kappa'] / beta + self.acut * theta * x) * d / r
def interact1(self, a1, a2, d, r, p, ksi): x = exp(acut * (r - p['rc'])) theta = 1.0 / (1.0 + x) y = (0.5 * p['V0'] * exp(-p['kappa'] * (r / beta - p['s0'])) * ksi / p['gamma2'] * theta) self.energy -= y f = y * (p['kappa'] / beta + acut * theta * x) * d / r self.forces[a1] += f self.forces[a2] -= f self.sigma1[a1] += ...
self.sigma1[a1] += (exp(-p['eta2'] * (r - beta * p['s0'])) * ksi * theta / p['gamma1']) def interact2(self, a1, a2, d, r, p, ksi): x = exp(acut * (r - p['rc']))
self.sigma1[a1] += (exp(-p2['eta2'] * (r - beta * p2['s0'])) * ksi * theta / p1['gamma1']) def interact2(self, a1, a2, d, r, p1, p2, ksi): x = exp(self.acut * (r - self.rc))
def interact1(self, a1, a2, d, r, p, ksi): x = exp(acut * (r - p['rc'])) theta = 1.0 / (1.0 + x) y = (0.5 * p['V0'] * exp(-p['kappa'] * (r / beta - p['s0'])) * ksi / p['gamma2'] * theta) self.energy -= y f = y * (p['kappa'] / beta + acut * theta * x) * d / r self.forces[a1] += f self.forces[a2] -= f self.sigma1[a1] += ...
y = (exp(-p['eta2'] * (r - beta * p['s0'])) * ksi / p['gamma1'] * theta * self.deds[a1]) f = y * (p['eta2'] + acut * theta * x) * d / r
y = (exp(-p2['eta2'] * (r - beta * p2['s0'])) * ksi / p1['gamma1'] * theta * self.deds[a1]) f = y * (p2['eta2'] + self.acut * theta * x) * d / r
def interact2(self, a1, a2, d, r, p, ksi): x = exp(acut * (r - p['rc'])) theta = 1.0 / (1.0 + x) y = (exp(-p['eta2'] * (r - beta * p['s0'])) * ksi / p['gamma1'] * theta * self.deds[a1]) f = y * (p['eta2'] + acut * theta * x) * d / r self.forces[a1] -= f self.forces[a2] += f
def __init__(self): self.atoms = None def get_potential_energy(self, atoms): self.update(atoms) return self.atoms.GetPotentialEnergy() def get_forces(self, atoms): self.update(atoms) return np.array(self.atoms.GetCartesianForces()) def get_stress(self, atoms): self.update(atoms) return np.array(self.atoms.GetStress(...
pass
def __init__(self): self.atoms = None
node.appendChild(lNode)
if leftOperand: node.appendChild(lNode)
def buildOperation(self, expr): while expr and expr[0] == '(' and expr[len(expr)-1] == ')': expr = expr[1:len(expr)-1] # Left operand bracketCounter = 0 i = 0 while i < len(expr) and (isVarChar(expr[i]) or expr[i] == '('): while bracketCounter > 0 or (i < len(expr) and expr[i] == '('): if expr[i] == '(': bracketCounte...
print(expr)
print("buildXMLTree: " + expr)
def buildXMLTree(self, expr): self.doc = parseString("<expr></expr>") node = self.doc.documentElement print(expr) expr = self.buildCleanExpr(expr) opNode = self.buildOperation(expr) node.appendChild(opNode) return node.firstChild
if (end >= len(expr) or expr[end] != ')'): expr = expr[:lastOccurence - len(operandLeft)] + "(" + operandLeft + op.text + operandRight + ")" + expr[lastOccurence + len(op.text) + len(operandRight):]
print(end) start = lastOccurence - 1 if (start < 0 or expr[start] != '(') or (end >= len(expr) or expr[end] != ')'): expr = expr[:lastOccurence] + "(" + op.text + operandRight + ")" + expr[lastOccurence + len(op.text) + len(operandRight):]
def buildCleanExpr(self, expr): expr = expr.replace(" ", "") # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) while lastOccurence is not -1: if lastOccurence == len(expr) - 1: raise CompilerException...
if (node is not None) and (node.nodeType != Node.TEXT_NODE or node.nodeValue != ""): if tabCount > lastTabCount: self.currentNode = lastNode codeTags = self.currentNode.getElementsByTagName("code") if not codeTags: codeTags = self.currentNode.getElementsByTagName("public") if not codeTags: codeTags = self.currentNode....
if tabCount > lastTabCount: self.currentNode = lastNode codeTags = self.currentNode.getElementsByTagName("code") if not codeTags: codeTags = self.currentNode.getElementsByTagName("public") if not codeTags: codeTags = self.currentNode.getElementsByTagName("private") if codeTags: self.currentNode = codeTags[0] if node...
def compileCodeToXML(self, code): lines = code.split('\n') + ["__bp__EOM"] self.doc = parseString("<module><header><title/><dependencies/></header><code></code></module>") self.initExprParser() root = self.doc.documentElement lastTabCount = 0 self.currentNode = root.getElementsByTagName("code")[0] lastNode = self.curr...
atTab -= 1
else: self.currentNode = self.currentNode.parentNode atTab -= 1 if nodeIsValid:
def compileCodeToXML(self, code): lines = code.split('\n') + ["__bp__EOM"] self.doc = parseString("<module><header><title/><dependencies/></header><code></code></module>") self.initExprParser() root = self.doc.documentElement lastTabCount = 0 self.currentNode = root.getElementsByTagName("code")[0] lastNode = self.curr...
else:
else: if nodeIsValid:
def compileCodeToXML(self, code): lines = code.split('\n') + ["__bp__EOM"] self.doc = parseString("<module><header><title/><dependencies/></header><code></code></module>") self.initExprParser() root = self.doc.documentElement lastTabCount = 0 self.currentNode = root.getElementsByTagName("code")[0] lastNode = self.curr...
if nodeIsValid:
def compileCodeToXML(self, code): lines = code.split('\n') + ["__bp__EOM"] self.doc = parseString("<module><header><title/><dependencies/></header><code></code></module>") self.initExprParser() root = self.doc.documentElement lastTabCount = 0 self.currentNode = root.getElementsByTagName("code")[0] lastNode = self.curr...
for op in opLevel.operators: lastOccurence = expr.find(op.text) while lastOccurence is not -1: if lastOccurence == len(expr) - 1: raise CompilerException("Missing operand") if isVarChar(expr[lastOccurence + len(op.text)]) or expr[lastOccurence + len(op.text)] == '(' or op.text == '(' or expr[lastOccurence + len(op.text...
i = 0 while i < len(expr): for op in opLevel.operators: if i < len(expr) - op.textLen and expr[i:i+op.textLen] == op.text: lastOccurence = i else: lastOccurence = -1 if lastOccurence is not -1: if lastOccurence == len(expr) - 1: raise CompilerException("Missing operand") if isVarChar(expr[lastOccurence + len(op.text)...
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
if expr[start] == ')' or expr[start] == ']': bracketCounter += 1 elif expr[start] == '(' or expr[start] == '[': bracketCounter -= 1 start -= 1 operandLeft = expr[start+1:lastOccurence]; end = lastOccurence + op.textLen while end < len(expr) and (isVarChar(expr[end]) or (expr[end] == '(' and end == lastOccurence + 1)...
operandLeft = expr[start+1:lastOccurence]; end = lastOccurence + op.textLen
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
while bracketCounter > 0 and end < len(expr): if expr[end] == '(' or expr[end] == '[': bracketCounter += 1 print(bracketCounter) elif expr[end] == ')' or expr[end] == ']': bracketCounter -= 1 print(bracketCounter) if bracketCounter == 1 and op.text != '[' and op.text != '(': end -= 1 bracketCounter = 0 elif bracketCoun...
while end < len(expr) and (bracketCounter > 0 or isVarChar(expr[end]) or (end == lastOccurence + 1 and (expr[end] == '(' or expr[end] == '['))): while bracketCounter > 0 and end < len(expr): if expr[end] == '(' or expr[end] == '[': bracketCounter += 1 print(bracketCounter) elif expr[end] == ')' or expr[end] == ']': br...
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
end += 1 operandRight = expr[lastOccurence + op.textLen:end]; print(self.getDebugPrefix() + " * buildCleanExpr.operators: " + operandLeft + " [" + op.text + "] " + operandRight) if operandLeft and (operandRight and ((start < 0 or expr[start] != '(') or (end >= len(expr) or expr[end] != ')')) or op.te...
operandRight = expr[lastOccurence + op.textLen:end]; print(self.getDebugPrefix() + " * buildCleanExpr.operators: " + operandLeft + " [" + op.text + "] " + operandRight) if operandLeft and (operandRight and ((start < 0 or expr[start] != '(') or (end >= len(expr) or expr[end] != ')')) or op.text == "(")...
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
expr = expr[:lastOccurence - len(operandLeft)] + "(" + operandLeft + op.text + operandRight + ")" + expr[lastOccurence + len(op.text) + len(operandRight):] print(self.getDebugPrefix() + " * Expression changed: " + expr)
print(self.getDebugPrefix() + " * Expression change denied for operator: [" + op.text + "]") elif op.type == Operator.UNARY and (lastOccurence <= 0 or (isVarChar(expr[lastOccurence - 1]) == False and expr[lastOccurence - 1] != ')')): end = lastOccurence + op.textLen while end < len(expr) and (isVarChar(expr[e...
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
print(self.getDebugPrefix() + " * Expression change denied for operator: [" + op.text + "]") elif op.type == Operator.UNARY and (lastOccurence <= 0 or (isVarChar(expr[lastOccurence - 1]) == False and expr[lastOccurence - 1] != ')')): end = lastOccurence + op.textLen while end < len(expr) and (isVarChar(expr[e...
if not self.similarOperatorExists(op): raise CompilerException("Syntax error concerning the unary operator [" + op.text + "]") elif expr[lastOccurence + len(op.text)] != '(' and expr[lastOccurence + len(op.text)] != '[': if self.similarOperatorExists(op): pass
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
pass else: if not self.similarOperatorExists(op): raise CompilerException("Syntax error concerning the unary operator [" + op.text + "]") elif expr[lastOccurence + len(op.text)] != '(' and expr[lastOccurence + len(op.text)] != '[': if self.similarOperatorExists(op): pass else: raise CompilerException("Operator [" + o...
raise CompilerException("Operator [" + op.text + "] expects a valid expression (encountered '" + expr[lastOccurence + len(op.text)] + "')") i += op.textLen else: i += 1
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
if isVarChar(expr[lastOccurence+1]) and expr[lastOccurence+1] != '(':
if isVarChar(expr[lastOccurence + len(op.text)]) or expr[lastOccurence + len(op.text)] == '(':
def buildCleanExpr(self, expr): expr = expr.replace(" ", "") print("buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) while lastOccurence is not -1: if lastOccurence == len(...
return line[:pos]
return line[:pos].rstrip()
def removeComments(self, line): pos = line.find('#') if pos is not -1: return line[:pos] else: return line
node = self.parseExpr(line) if node is None: raise CompilerException("Unknown command")
if startswith(line, "import"): node = self.doc.createElement("import") node.appendChild(self.parseExpr(line[len("import")+1:])) elif startswith(line, "return"): node = self.doc.createElement("return") param = self.parseExpr(line[len("return")+1:]) if param.nodeValue or param.hasChildNodes(): node.appendChild(param) els...
def parseLine(self, line): node = None # Blocks if self.nextLineIndented: if startswith(line, "if"): node = self.doc.createElement("if-block") ifNode = self.doc.createElement("if") condition = self.doc.createElement("condition") code = self.doc.createElement("code") condition.appendChild(self.parseExpr(line[len("if"...
while start >= 0 and (isVarChar(expr[start]) or (expr[start] == ')' and start == lastOccurence - 1)): if expr[start] == ')':
while start >= 0 and (isVarChar(expr[start]) or ((expr[start] == ')' or expr[start] == ']') and start == lastOccurence - 1)): if expr[start] == ')' or expr[start] == ']':
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
if expr[start] == ')':
if expr[start] == ')' or expr[start] == ']':
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
elif expr[start] == '(':
elif expr[start] == '(' or expr[start] == '[':
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
pass
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
while end < len(expr) and (isVarChar(expr[end]) or (expr[end] == '(' and end == lastOccurence + 1)): if op.text == '[' or op.text == '(' or (expr[end] == '(' and end == lastOccurence + 1):
while end < len(expr) and (isVarChar(expr[end]) or (expr[end] == '(' and end == lastOccurence + 1) or (expr[end] == '[' and end == lastOccurence + 1)): if op.text == '[' or op.text == '(' or (expr[end] == '(' and end == lastOccurence + 1) or (expr[end] == '[' and end == lastOccurence + 1):
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
while bracketCounter > 0 and end < len(expr)-1: end += 1
while bracketCounter > 0 and end < len(expr):
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
if bracketCounter == 0: end -= 1
print(bracketCounter) if bracketCounter == 0: end -= 2 end += 1
def buildCleanExpr(self, expr): self.recursionLevel += 1 expr = expr.replace(" ", "") print(self.getDebugPrefix() + " * buildCleanExpr: " + expr) # For every operator level for opLevel in self.operatorLevels: # For every operator in the current level for op in opLevel.operators: lastOccurence = expr.find(op.text) wh...
while bracketCounter > 0 or (i < len(expr) and expr[i] == '('): if expr[i] == '(':
while i < len(expr) and (bracketCounter > 0 or expr[i] == '('): if expr[i] == '(' or expr[i] == '[':
def buildOperation(self, expr): self.recursionLevel += 1 # Debug info print(self.getDebugPrefix() + " * buildOperation.dirty: " + expr) # Remove unnecessary brackets bracketCounter = 0 i = len(expr) while expr and expr[0] == '(' and expr[len(expr)-1] == ')' and bracketCounter == 0 and i == len(expr): #print("WHIIIIIL...
elif expr[i] == ')':
elif expr[i] == ')' or expr[i] == ']':
def buildOperation(self, expr): self.recursionLevel += 1 # Debug info print(self.getDebugPrefix() + " * buildOperation.dirty: " + expr) # Remove unnecessary brackets bracketCounter = 0 i = len(expr) while expr and expr[0] == '(' and expr[len(expr)-1] == ')' and bracketCounter == 0 and i == len(expr): #print("WHIIIIIL...
def show_imshow_popup_menu(self, (x, y), image, subplot=''): popup = wx.Menu() show_hist_item = wx.MenuItem(popup, -1, 'Show image histogram') popup.AppendItem(show_hist_item) def show_hist(evt): new_title = '%s %s image histogram'%(self.Title, subplot) fig = create_or_find(self, -1, new_title, subplots=(1,1), name=new...
def show_imshow_popup_menu(self, (x, y), image, subplot): ''' shows a popup menu at pos x,y with items to: - Show image histogram - Change contrast stretching ''' if 'popup_menus' not in self.__dict__: self.popup_menus = {} popup = self.popup_menus.get(subplot, None) if popup == None: MENU_CONTRAST_NORMAL = wx.NewId(...
def show_imshow_popup_menu(self, (x, y), image, subplot=''): popup = wx.Menu() show_hist_item = wx.MenuItem(popup, -1, 'Show image histogram') popup.AppendItem(show_hist_item) def show_hist(evt): new_title = '%s %s image histogram'%(self.Title, subplot) fig = create_or_find(self, -1, new_title, subplots=(1,1), name=new...
self.dpi = cps.Float( "Resolution (pixels per inch)",96.0,minval=1.0, doc="""This is the resolution to be used when displaying the image (in pixels per inch).""")
self.font_size = cps.Integer( "Font size (points)", 12, minval=1) self.decimals = cps.Integer( "Number of decimals", 2, minval=0)
def object_fn(): if self.objects_or_image == OI_OBJECTS: return self.objects_name.value else: return cpmeas.IMAGE
self.dpi, self.saved_image_contents]
self.font_size, self.decimals, self.saved_image_contents]
def settings(self): """Return the settings to be loaded or saved to/from the pipeline These are the settings (from cellprofiler.settings) that are either read from the strings in the pipeline or written out to the pipeline. The settings should appear in a consistent order so they can be matched to the strings in the p...
self.display_image, self.dpi, self.saved_image_contents]
self.display_image, self.font_size, self.decimals, self.saved_image_contents]
def visible_settings(self): """The settings that are visible in the UI """ result = [self.objects_or_image] if self.objects_or_image == OI_OBJECTS: result += [self.objects_name] result += [self.measurement, self.image_name, self.text_color, self.display_image, self.dpi, self.saved_image_contents] return result
if self.saved_image_contents != E_FIGURE: my_dpi = self.dpi.value * 2 height = float(image.pixel_data.shape[0]) * 4.0 / my_dpi width = float(image.pixel_data.shape[1]) *4.0 / my_dpi figure = matplotlib.figure.Figure(figsize=(width, height)) else: my_dpi = self.dpi.value * 2 height = float(image.pixel_data.shape[0]) *...
figure = matplotlib.figure.Figure()
def run(self, workspace): import matplotlib import matplotlib.backends.backend_wxagg from cellprofiler.gui.cpfigure import figure_to_image # # Get the image # image = workspace.image_set.get_image(self.image_name.value) workspace.display_data.pixel_data = image.pixel_data # # Get the measurements and positions # measur...
figure_frame.figure.set_dpi(self.dpi.value)
def display(self, workspace): figure_frame = workspace.create_or_find_figure() figure_frame.clf() figure_frame.figure.set_dpi(self.dpi.value) self.display_on_figure(workspace, figure_frame.figure)
if round(fvalue) == value: svalue = str(value) else: svalue = round(fvalue,3)
svalue = "%.*f"%(self.decimals.value, value)
def display_on_figure(self, workspace, figure): import matplotlib axes = figure.add_subplot(1,1,1) assert isinstance(axes, matplotlib.axes.Axes) axes.set_title("%s\n%s" % (self.objects_name.value, self.measurement.value), fontname = cpprefs.get_title_font_name(), fontsize = cpprefs.get_title_font_size()) axes_image = a...
subplots = (2,3) subplot_indices = ((0,0),(0,1),(1,0),(1,1),(2,2)) color_subplot = (1,2)
subplots = (3,2) subplot_indices = ((0,0),(0,1),(1,0),(1,1),(2,0)) color_subplot = (2,1)
def run(self,workspace): parent_image = None parent_image_name = None imgset = workspace.image_set rgb_pixel_data = None input_image_settings = [] for color_scheme_setting in self.color_scheme_settings: if color_scheme_setting.image_name.is_blank: continue input_image_settings.append(color_scheme_setting.image_name) im...
my_frame.subplot_imshow(1,1,rgb_pixel_data, title=self.rgb_image_name.value)
my_frame.subplot_imshow(color_subplot[0], color_subplot[1] ,rgb_pixel_data, title=self.rgb_image_name.value)
def run(self,workspace): parent_image = None parent_image_name = None imgset = workspace.image_set rgb_pixel_data = None input_image_settings = [] for color_scheme_setting in self.color_scheme_settings: if color_scheme_setting.image_name.is_blank: continue input_image_settings.append(color_scheme_setting.image_name) im...
from AppKit import NSWindow, NSApp, NSFloatingWindowLevel window_ref = self.MacGetTopLevelWindowRef() print "window_ref =", window_ref nsw = NSWindow.alloc().initWithWindowRef_(window_ref) print "nsw =", nsw nsw.setLevel_(NSFloatingWindowLevel)
try: from AppKit import NSWindow, NSApp, NSFloatingWindowLevel window_ref = self.MacGetTopLevelWindowRef() nsw = NSWindow.alloc().initWithWindowRef_(window_ref) nsw.setLevel_(NSFloatingWindowLevel) except ImportError: print "No AppKit module => can't make progress window stay on top."
def __init__(self, *args, **kwds): if sys.platform.startswith("win"): kwds["style"] = wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP wx.Frame.__init__(self, *args, **kwds) self.Show() if wx.Platform == '__WXMAC__' and hasattr(self, 'MacGetTopLevelWindowRef'): from AppKit import NSWindow, NSApp, NSFloatingWindowLevel window_re...
"Font size (points)", 12, minval=1)
"Font size (points)", 10, minval=1)
def object_fn(): if self.objects_or_image == OI_OBJECTS: return self.objects_name.value else: return cpmeas.IMAGE
figure = matplotlib.figure.Figure() self.display_on_figure(workspace, figure)
fig = self.display_on_figure(workspace)
def run(self, workspace): import matplotlib import matplotlib.backends.backend_wxagg from cellprofiler.gui.cpfigure import figure_to_image # # Get the image # image = workspace.image_set.get_image(self.image_name.value) workspace.display_data.pixel_data = image.pixel_data # # Get the measurements and positions # measur...
figure.subplots_adjust(0,0,1,1,0,0)
fig.figure.subplots_adjust(0,0,1,1,0,0)
def run(self, workspace): import matplotlib import matplotlib.backends.backend_wxagg from cellprofiler.gui.cpfigure import figure_to_image # # Get the image # image = workspace.image_set.get_image(self.image_name.value) workspace.display_data.pixel_data = image.pixel_data # # Get the measurements and positions # measur...
figure.subplots_adjust(0,0,1,1,0,0) axes = figure.axes[0] assert isinstance(axes,matplotlib.axes.Axes) axes.set_axis_off()
fig.figure.subplots_adjust(0,0,1,1,0,0) fig.subplot(0,0).set_axis_off()
def run(self, workspace): import matplotlib import matplotlib.backends.backend_wxagg from cellprofiler.gui.cpfigure import figure_to_image # # Get the image # image = workspace.image_set.get_image(self.image_name.value) workspace.display_data.pixel_data = image.pixel_data # # Get the measurements and positions # measur...
canvas = matplotlib.backends.backend_wxagg.FigureCanvasAgg(figure) pixel_data = figure_to_image(figure)
canvas = fig.figure.canvas pixel_data = figure_to_image(fig.figure)
def run(self, workspace): import matplotlib import matplotlib.backends.backend_wxagg from cellprofiler.gui.cpfigure import figure_to_image # # Get the image # image = workspace.image_set.get_image(self.image_name.value) workspace.display_data.pixel_data = image.pixel_data # # Get the measurements and positions # measur...
figure_frame = workspace.create_or_find_figure() figure_frame.clf() self.display_on_figure(workspace, figure_frame.figure) def display_on_figure(self, workspace, figure): import matplotlib axes = figure.add_subplot(1,1,1) assert isinstance(axes, matplotlib.axes.Axes) axes.set_title("%s\n%s" % (self.objects_name.value,...
self.display_on_figure(workspace) def display_on_figure(self, workspace): import matplotlib.cm fig = workspace.create_or_find_figure(title="Display data on image", subplots=(1,1)) fig.clf() title = "%s\n%s" % (self.objects_name.value, self.measurement.value) fig.subplot_imshow(0, 0, workspace.display_data.pixel_data, ...
def display(self, workspace): figure_frame = workspace.create_or_find_figure() figure_frame.clf() self.display_on_figure(workspace, figure_frame.figure)
axes.add_artist(text)
fig.subplot(0,0).add_artist(text) return fig
def display_on_figure(self, workspace, figure): import matplotlib axes = figure.add_subplot(1,1,1) assert isinstance(axes, matplotlib.axes.Axes) axes.set_title("%s\n%s" % (self.objects_name.value, self.measurement.value), fontname = cpprefs.get_title_font_name(), fontsize = cpprefs.get_title_font_size()) axes_image = a...
if mask is None:
if mask is None and not image.has_crop_mask:
def check_expected(self, image, expected, mask=None): if mask is None: self.assertTrue(np.all(np.abs(image.pixel_data - expected < np.sqrt(np.finfo(float).eps)))) self.assertFalse(image.has_mask) else: self.assertTrue(image.has_mask) self.assertTrue(np.all(mask == image.mask)) self.assertTrue(np.all(np.abs(image.pixel_...
self.assertTrue(np.all(mask == image.mask)) self.assertTrue(np.all(np.abs(image.pixel_data[mask] - expected[mask]) <
if not image.has_crop_mask: self.assertTrue(np.all(mask == image.mask)) self.assertTrue(np.all(np.abs(image.pixel_data[image.mask] - expected[image.mask]) <
def check_expected(self, image, expected, mask=None): if mask is None: self.assertTrue(np.all(np.abs(image.pixel_data - expected < np.sqrt(np.finfo(float).eps)))) self.assertFalse(image.has_mask) else: self.assertTrue(image.has_mask) self.assertTrue(np.all(mask == image.mask)) self.assertTrue(np.all(np.abs(image.pixel_...
print "<tr>%s</tr>"% groups[i][0][key]
print "<td>%s</td>"% groups[i][0][key]
def error_callback(event, caller): if (isinstance(event, cpp.LoadExceptionEvent) or isinstance(event, cpp.RunExceptionEvent)): sys.stderr.write("Handling exception: %s\n"%str(event)) sys.stderr.write(traceback.format_exc()) had_problem = [True]
if self.db_type != DB_SQLITE:
if self.db_type == DB_MYSQL or self.db_type == DB_ORACLE:
def write_properties(self, workspace): """Write the CellProfiler Analyst properties file""" # # Find the primary object # for object_name in workspace.measurements.get_object_names(): if object_name == 'Image': continue if self.ignore_object(object_name): continue supposed_primary_object = object_name # # Find all imag...
else:
elif self.db_type == DB_SQLITE:
def write_properties(self, workspace): """Write the CellProfiler Analyst properties file""" # # Find the primary object # for object_name in workspace.measurements.get_object_names(): if object_name == 'Image': continue if self.ignore_object(object_name): continue supposed_primary_object = object_name # # Find all imag...
elif self.db_type == DB_MYSQL_CSV: db_info = 'db_type = mysql\n' db_info += 'db_port = \n' db_info += 'db_host = \n' db_info += 'db_name = %(db_name)s\n'%(locals()) db_info += 'db_user = \n' db_info += 'db_passwd = '
def write_properties(self, workspace): """Write the CellProfiler Analyst properties file""" # # Find the primary object # for object_name in workspace.measurements.get_object_names(): if object_name == 'Image': continue if self.ignore_object(object_name): continue supposed_primary_object = object_name # # Find all imag...
print "command = " +cmd print "bindings = " + str(bindings)
def CreateBatchRecord(my_batch): """Create a record in batchprofiler.batch Uses global variables, recipient, data_dir, queue, batch_size, write_data, timeout and connection Returns: batch_id """ cursor = connection.cursor() cmd = """ insert into batch (batch_id, email, data_dir, queue, batch_size, write_data, timeout,...
run["group_or_null"] = "null"
run["group_or_null"] = None
def pack_group(run): '''Convert the 'group' field into the database field''' if not run.has_key("group"): run["group_or_null"] = "null" return if run["group"] is None: run["group_or_null"] = "null" return run["group_or_null"] = ','.join(['='.join([encode_group_string(x) for x in item]) for item in run["group"].items()]...
kvs = re.split('(?<!\\\\),',run["group_or_null"][1:-1])
kvs = re.split('(?<!\\\\),',run["group_or_null"])
def unpack_group(run): if run["group_or_null"] is None: run["group"] = None else: kvs = re.split('(?<!\\\\),',run["group_or_null"][1:-1]) kvpairs = [[decode_group_string(x) for x in re.split('(?<!\\\\)=',kv)] for kv in kvs] run["group"] = dict(kvpairs)
sql=""" insert into run (run_id, batch_id, bstart,bend,bgroup, status_file_name) values (null,%s,%s,%s,%s,%s)""" bindings = [run[x] for x in ( 'batch_id','start','end','group_or_null','status_file_name')]
if run["group_or_null"] is None: sql = ("insert into run " "(run_id, batch_id, bstart, bend, bgroup, status_file_name) " "values (null, %s, %s, %s, null, %s)") binding_names = ('batch_id', 'start', 'end', 'status_file_name') else: sql= ("insert into run " "(run_id, batch_id, bstart,bend,bgroup, status_file_name)" "valu...
def CreateRunRecord(batch_id, run): """Create a run record within the current batch """ run["batch_id"]=batch_id pack_group(run) cursor = connection.cursor() sql=""" insert into run (run_id, batch_id, bstart,bend,bgroup, status_file_name) values (null,%s,%s,%s,%s,%s)""" bindings = [run[x] for x in ( 'batch_id','start'...
self.outlines_name = cps.ImageNameProvider(
self.outlines_name = cps.OutlineNameProvider(
def create_settings(self): '''Create the settings that control this module''' self.object_name = cps.ObjectNameSubscriber( "Objects to be masked:","None", doc="""These are the objects that will be masked by the masking objects or image. You can choose from any objects created by a previous module, such as <b>IdentifyPr...
if self.wants_outlines:
if self.wants_outlines.value:
def visible_settings(self): '''The settings as they appear in the UI''' result = [self.object_name, self.remaining_objects, self.mask_choice, self.masking_image if self.mask_choice == MC_IMAGE else self.masking_objects, self.overlap_choice]
if self.wants_outlines:
if self.wants_outlines.value:
def run(self, workspace): '''Run the module on an image set''' object_name = self.object_name.value remaining_object_name = self.remaining_objects.value original_objects = workspace.object_set.get_objects(object_name) if self.mask_choice == MC_IMAGE: mask = workspace.image_set.get_image(self.masking_image.value, must...
(min, max) = (im.min(), im.max()) if np.any((im>min)&(im<max)): im = im.clip(im[im>0].min(), im.max()) im = np.log(im) im -= im.min() if im.max() > 0: im /= im.max()
(min, max) = (im[im > 0].min(), im.max()) if (max > min) and (max > 0): return (np.log(im.clip(min, max)) - np.log(min)) / (np.log(max) - np.log(min))
def log_transform(im): '''returns log(image) scaled to the interval [0,1]''' (min, max) = (im.min(), im.max()) if np.any((im>min)&(im<max)): im = im.clip(im[im>0].min(), im.max()) im = np.log(im) im -= im.min() if im.max() > 0: im /= im.max() return im
def show_imshow_popup_menu(self, (x, y), image, subplot):
def show_imshow_popup_menu(self, (x, y), image, subplot, imshow_kwargs):
def show_imshow_popup_menu(self, (x, y), image, subplot): ''' shows a popup menu at pos x,y with items to: - Show image histogram - Change contrast stretching ''' # Manage a dict of popup menus keyed by each subplot (x,y) location if 'popup_menus' not in self.__dict__: self.popup_menus = {} params = self.subplot_param...
if params['normalize'] == 'log':
if imshow_kwargs['normalize'] == 'log':
def show_imshow_popup_menu(self, (x, y), image, subplot): ''' shows a popup menu at pos x,y with items to: - Show image histogram - Change contrast stretching ''' # Manage a dict of popup menus keyed by each subplot (x,y) location if 'popup_menus' not in self.__dict__: self.popup_menus = {} params = self.subplot_param...
elif params['normalize'] == True:
elif imshow_kwargs['normalize'] == True:
def show_imshow_popup_menu(self, (x, y), image, subplot): ''' shows a popup menu at pos x,y with items to: - Show image histogram - Change contrast stretching ''' # Manage a dict of popup menus keyed by each subplot (x,y) location if 'popup_menus' not in self.__dict__: self.popup_menus = {} params = self.subplot_param...
elif params['normalize'] == False:
else:
def show_imshow_popup_menu(self, (x, y), image, subplot): ''' shows a popup menu at pos x,y with items to: - Show image histogram - Change contrast stretching ''' # Manage a dict of popup menus keyed by each subplot (x,y) location if 'popup_menus' not in self.__dict__: self.popup_menus = {} params = self.subplot_param...
fig.subplot_imshow(0, 0, self.images[subplot])
fig.subplot_imshow(0, 0, self.images[subplot], **imshow_kwargs)
def open_image_in_new_figure(evt): '''Callback for "Open image in new figure" popup menu item ''' new_title = self.subplot(subplot[0], subplot[1]).get_title() fig = create_or_find(self, -1, new_title, subplots=(1,1), name=new_title) fig.subplot_imshow(0, 0, self.images[subplot]) fig.figure.canvas.draw()
self.subplot_imshow(subplot[0], subplot[1], self.images[subplot])
self.subplot_imshow(subplot[0], subplot[1], self.images[subplot], **imshow_kwargs)
def change_contrast(evt): '''Callback for Image contrast menu items''' if evt.Id == MENU_CONTRAST_RAW: params['normalize'] = False elif evt.Id == MENU_CONTRAST_NORMALIZED: params['normalize'] = True elif evt.Id == MENU_CONTRAST_LOG: params['normalize'] = 'log' self.subplot_imshow(subplot[0], subplot[1], self.images[sub...
item = submenu.Append(MENU_CHANNELS_RED, 'Red', 'Show/Hide the red channel', wx.ITEM_CHECK) if params['rgb_mask'][0]: item.Check() item = submenu.Append(MENU_CHANNELS_GREEN, 'Green', 'Show/Hide the green channel', wx.ITEM_CHECK) if params['rgb_mask'][1]: item.Check() item = submenu.Append(MENU_CHANNELS_BLUE, 'Blue', 'S...
item_r = submenu.Append(MENU_CHANNELS_RED, 'Red', 'Show/Hide the red channel', wx.ITEM_CHECK) item_g = submenu.Append(MENU_CHANNELS_GREEN, 'Green', 'Show/Hide the green channel', wx.ITEM_CHECK) item_b = submenu.Append(MENU_CHANNELS_BLUE, 'Blue', 'Show/Hide the blue channel', wx.ITEM_CHECK) if imshow_kwargs['rgb_mask'][...
def change_contrast(evt): '''Callback for Image contrast menu items''' if evt.Id == MENU_CONTRAST_RAW: params['normalize'] = False elif evt.Id == MENU_CONTRAST_NORMALIZED: params['normalize'] = True elif evt.Id == MENU_CONTRAST_LOG: params['normalize'] = 'log' self.subplot_imshow(subplot[0], subplot[1], self.images[sub...
self.subplot_imshow(subplot[0], subplot[1], self.images[subplot])
self.subplot_imshow(subplot[0], subplot[1], self.images[subplot], **imshow_kwargs)
def toggle_channels(evt): '''Callback for channel menu items.''' if 'rgb_mask' not in params: params['rgb_mask'] = [1, 1, 1] if evt.Id == MENU_CHANNELS_RED: params['rgb_mask'][0] = not params['rgb_mask'][0] elif evt.Id == MENU_CHANNELS_GREEN: params['rgb_mask'][1] = not params['rgb_mask'][1] elif evt.Id == MENU_CHANNEL...
self.subplot_params[(x,y)] = params = {} from inspect import getargspec args, _, _, default_vals = getargspec(self.subplot_imshow) defaults = dict(zip(args[-len(default_vals):], default_vals)) for arg in defaults.keys(): if (locals()[arg] != defaults[arg]) or (arg not in params): params[arg] = locals()[arg] params = ...
self.subplot_params[(x,y)] = {} kwargs.update(self.subplot_params[(x,y)]) title = kwargs['title'] clear = kwargs['clear'] colormap = kwargs['colormap'] colorbar = kwargs['colorbar'] normalize = kwargs['normalize'] vmin = kwargs['vmin'] vmax = kwargs['vmax'] rgb_mask = kwargs['rgb_mask']
def subplot_imshow(self, x,y, image, title=None, clear=True, colormap=None, colorbar=False, normalize=True, vmin=0, vmax=1, rgb_mask=[1,1,1]): '''Show an image in a subplot x, y - show image in this subplot image - image to show title - add this title to the subplot clear - clear the subplot axes before display if tr...
image = log_transform(image)
else: image = log_transform(image)
def subplot_imshow(self, x,y, image, title=None, clear=True, colormap=None, colorbar=False, normalize=True, vmin=0, vmax=1, rgb_mask=[1,1,1]): '''Show an image in a subplot x, y - show image in this subplot image - image to show title - add this title to the subplot clear - clear the subplot axes before display if tr...
self.show_imshow_popup_menu((evt.x, self.figure.canvas.GetSize()[1]-evt.y), image, subplot=(x,y))
self.show_imshow_popup_menu((evt.x, self.figure.canvas.GetSize()[1]-evt.y), image, (x,y), kwargs)
def on_release(evt): if evt.inaxes == subplot: if evt.button != 1: self.show_imshow_popup_menu((evt.x, self.figure.canvas.GetSize()[1]-evt.y), image, subplot=(x,y))
elif control.Value != v.value:
elif control.Value != str(v.value):
def on_cell_change(event, setting = v, control=control): self.__on_cell_change(event, setting,control)
v, z, z_one_tailed, OrderedUniqueDoses, OrderedAverageValues = \ vz_factors(grouping_data, data)
z, z_one_tailed, OrderedUniqueDoses, OrderedAverageValues = \ z_factors(grouping_data, data) dose_data = measurements.get_all_measurements( cpmeas.IMAGE,self.dose_values[0].measurement.value) dose_data = np.array(dose_data).flatten() v = v_factors(dose_data, data)
def post_run(self, workspace): """Do post-processing after the run completes workspace - the workspace at the end of the run """ measurements = workspace.measurements assert isinstance(measurements, cpmeas.Measurements) all_objects = [x for x in measurements.get_object_names() if x not in [cpmeas.EXPERIMENT, cpmeas.NE...
def vz_factors(xcol, ymatr):
def z_factors(xcol, ymatr):
def vz_factors(xcol, ymatr): '''xcol is (Nobservations,1) column vector of grouping values (in terms of dose curve it may be Dose). ymatr is (Nobservations, Nmeasures) matrix, where rows correspond to observations and columns corresponds to different measures. returns v, z, z_one_tailed, OrderedUniqueDoses, OrderedAve...
v, z and z_bwtn_mean are (1, Nmeasures) row vectors containing V-, Z'- and
z and z_bwtn_mean are (1, Nmeasures) row vectors containing Z'- and
def vz_factors(xcol, ymatr): '''xcol is (Nobservations,1) column vector of grouping values (in terms of dose curve it may be Dose). ymatr is (Nobservations, Nmeasures) matrix, where rows correspond to observations and columns corresponds to different measures. returns v, z, z_one_tailed, OrderedUniqueDoses, OrderedAve...
When ranges are zero, we set the V and Z' factors to a very negative
When ranges are zero, we set the Z' factors to a very negative
def vz_factors(xcol, ymatr): '''xcol is (Nobservations,1) column vector of grouping values (in terms of dose curve it may be Dose). ymatr is (Nobservations, Nmeasures) matrix, where rows correspond to observations and columns corresponds to different measures. returns v, z, z_one_tailed, OrderedUniqueDoses, OrderedAve...
vrange = np.max(avers,0) - np.min(avers,0) vstd = np.zeros(len(vrange)) vstd[vrange == 0] = 1; vstd[vrange != 0] = np.mean(stds[:,vrange !=0], 0) vrange[vrange == 0] = 0.000001; v = 1 - 6 * (vstd / vrange)
def vz_factors(xcol, ymatr): '''xcol is (Nobservations,1) column vector of grouping values (in terms of dose curve it may be Dose). ymatr is (Nobservations, Nmeasures) matrix, where rows correspond to observations and columns corresponds to different measures. returns v, z, z_one_tailed, OrderedUniqueDoses, OrderedAve...
return (v, z, z_one_tailed, xs, avers)
return (z, z_one_tailed, xs, avers) def v_factors(xcol, ymatr): '''xcol is (Nobservations,1) column vector of grouping values (in terms of dose curve it may be Dose). ymatr is (Nobservations, Nmeasures) matrix, where rows correspond to observations and columns corresponds to different measures. Calculate the V factor...
def vz_factors(xcol, ymatr): '''xcol is (Nobservations,1) column vector of grouping values (in terms of dose curve it may be Dose). ymatr is (Nobservations, Nmeasures) matrix, where rows correspond to observations and columns corresponds to different measures. returns v, z, z_one_tailed, OrderedUniqueDoses, OrderedAve...
i = 0 for result in results:
for i,result in enumerate(results):
def error_callback(event, caller): if (isinstance(event, cpp.LoadExceptionEvent) or isinstance(event, cpp.RunExceptionEvent)): sys.stderr.write("Handling exception: %s\n"%str(event)) sys.stderr.write(traceback.format_exc()) had_problem = [True]
return "0"
return END
def get_display_max(self): """What to display for the maximum""" if self.unbounded_max: return "0" elif self.max is not None: return str(abs(self.max)) else: return str(self.max).split(',')[1]
return str(self.max).split(',')[1]
return str(self).split(',')[1]
def get_display_max(self): """What to display for the maximum""" if self.unbounded_max: return "0" elif self.max is not None: return str(abs(self.max)) else: return str(self.max).split(',')[1]
frame = ImageFrame(self.__list_box.GetTopLevelParent(), filename, image=handles["Image"]) frame.Show()
image=handles["Image"] frame = FIG.CPFigureFrame(self.__list_box.GetTopLevelParent(), title = filename, subplots = (1,1)) if image.ndim == 3: frame.subplot_imshow_color(0,0,image,filename) else: frame.subplot_imshow_grayscale(0,0,image,filename) frame.Refresh()
def __display_matlab_image(self,handles, filename): frame = ImageFrame(self.__list_box.GetTopLevelParent(), filename, image=handles["Image"]) frame.Show()
lookup = np.array(lookup, int)
lookup = fix(lookup)
def run(self, workspace): assert isinstance(workspace, cpw.Workspace) image = workspace.image_set.get_image(self.image_name.value, must_be_grayscale = True) img = image.pixel_data mask = image.mask objects = workspace.object_set.get_objects(self.primary_objects.value) global_threshold = None if self.method == M_DISTANC...
import cellprofiler.cpmodule as cpm assert isinstance(module, cpm.CPModule)
print "Populating %s at %d" % (module.module_name, module.module_num)
def __populate_row(self, module): """Populate a row in the grid with a module.""" import cellprofiler.cpmodule as cpm assert isinstance(module, cpm.CPModule) row = module.module_num-1 pause_item = wx.ListItem() pause_item.Mask = wx.LIST_MASK_IMAGE pause_item.Image = get_image_index(NOTDEBUG) pause_item.Column = PAUSE_C...
else: start = event.module_num - 1
def __on_module_moved(self,pipeline,event): if event.direction == cellprofiler.pipeline.DIRECTION_UP: start = event.module_num - 2 else: start = event.module_num - 1 first_selected = self.list_ctrl.IsSelected(start) second_selected = self.list_ctrl.IsSelected(start+1) self.list_ctrl.DeleteItem(start) self.list_ctrl.Del...
if self.source.value == cpmeas.IMAGE and
if self.source.value == cpmeas.IMAGE:
def run(self, workspace): m = workspace.get_measurements() if self.source.value == cpmeas.IMAGE and x = m.get_all_measurements(cpmeas.IMAGE, self.y_axis.value) y = m.get_all_measurements(cpmeas.IMAGE, self.y_axis.value) else: x = m.get_current_measurement(self.get_x_object(), self.x_axis.value) y = m.get_current_measur...
aux_button_box.Add(report_button, 0, wx.EXPAND | wx.Bottom, 5)
aux_button_box.Add(report_button, 0, wx.EXPAND | wx.BOTTOM, 5)
def on_copy(event): if wx.TheClipboard.Open(): try: wx.TheClipboard.Clear() wx.TheClipboard.SetData(wx.TextDataObject(traceback_text)) wx.TheClipboard.Flush() finally: wx.TheClipboard.Close()
return all([getattr(provider.provided_attributes, key, None) ==
return all([provider.provided_attributes.get(key, None) ==
def matches(self, provider): '''Return true if the provider is compatible with this subscriber This method can be used to be more particular about the providers that are selected. For instance, if you want a list of only FileImageNameProviders (images loaded from files), you can check that here. ''' return all([getatt...
def _insert_file(self, row, file):
def _insert_file(self, row, file_):
def _insert_file(self, row, file): QtCore.QCoreApplication.processEvents() QtCore.QCoreApplication.sendPostedEvents() self._playlist_model.insertRows(row) self._playlist_model.setData( self._playlist_model.index(row, PlaylistModel.FILE), QtCore.QVariant(file))
QtCore.QVariant(file))
QtCore.QVariant(file_))
def _insert_file(self, row, file): QtCore.QCoreApplication.processEvents() QtCore.QCoreApplication.sendPostedEvents() self._playlist_model.insertRows(row) self._playlist_model.setData( self._playlist_model.index(row, PlaylistModel.FILE), QtCore.QVariant(file))
def file(self, file): self._file = file
def file(self, file_): self._file = file_
def file(self, file): self._file = file
files = [urllib.unquote(file.replace("file://", "")) for file in
files = [urllib.unquote(file_.replace("file://", "")) for file_ in
def dropMimeData(self, data, action, row, column, parent): if action == QtCore.Qt.IgnoreAction: return True if not data.hasFormat("text/uri-list"): return False row = 0 if parent.row() != -1: row = parent.row() raw_data = data.data("text/uri-list") files = [urllib.unquote(file.replace("file://", "")) for file in unicod...
def __init__(self, parent=None, filter=None):
def __init__(self, parent=None, filter_=None):
def __init__(self, parent=None, filter=None): super(SimpleDirModel, self).__init__(parent) self.setReadOnly(True) self.setLazyChildCount(True) self.setFilter( QtCore.QDir.AllDirs | QtCore.QDir.NoDotAndDotDot | QtCore.QDir.Files) self.setNameFilters(filter)
self.setNameFilters(filter)
self.setNameFilters(filter_)
def __init__(self, parent=None, filter=None): super(SimpleDirModel, self).__init__(parent) self.setReadOnly(True) self.setLazyChildCount(True) self.setFilter( QtCore.QDir.AllDirs | QtCore.QDir.NoDotAndDotDot | QtCore.QDir.Files) self.setNameFilters(filter)
self.connect( self.playlist_view, QtCore.SIGNAL("doubleClicked(QModelIndex)"), self.play)
self.playlist_view.doubleClicked.connect(self.play)
def _setup_playlist(self): self.playlist_view = QtGui.QTableView() self.playlist_view.setAcceptDrops(True) self.playlist_view.setDragEnabled(True) self.playlist_view.setDropIndicatorShown(True) self.playlist_view.setAlternatingRowColors(True)
self.dir_model = SimpleDirModel(filter=media_filter)
self.dir_model = SimpleDirModel(filter_=media_filter)
def _setup_widgets(self): self.dir_view = QtGui.QTreeView() self.dir_view.setSelectionMode( QtGui.QAbstractItemView.ContiguousSelection) media_filter = ["*%s" % extension for extension in self.playlist_model.media_file_extensions] self.dir_model = SimpleDirModel(filter=media_filter) self.dir_view.setModel(self.dir_mode...
self.playlist_layout = QtGui.QHBoxLayout()
self.playlist_layout = QtGui.QVBoxLayout()
def _setup_widgets(self): self.dir_view = QtGui.QTreeView() self.dir_view.setSelectionMode( QtGui.QAbstractItemView.ContiguousSelection) media_filter = ["*%s" % extension for extension in self.playlist_model.media_file_extensions] self.dir_model = SimpleDirModel(filter=media_filter) self.dir_view.setModel(self.dir_mode...