Is there a python-docx equivalent the following visual basic code? What is it? Pointers to the appropriate documentation or sample code would be great too.
With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(2)
.NumberFormat = "%1.%2"
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleLegal
.NumberPosition = InchesToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.5)
.TabPosition = wdUndefined
.ResetOnHigher = 1
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = False
.Superscript = False
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = False
.Hidden = False
.Underline = wdUnderlineNone
.Color = wdUndefined
.Size = 10.5
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "Times New Roman"
End With
.LinkedStyle = "L2"
End With
The goal is to be able to assign a paragraph a style with the appropriately linked numbering so that I can then assign the style to the paragraph and get well numbered lists automatically.
Related
I am studying with maya python api.
I'm making a simple mult_matrix node plugin, and for some reason, the multiplied output keeps coming out to zero. I'm going to receive the output by matrix.
Can you help me?
def compute(self,plug,data):
enter code here
if plug == node.Moutput:
readerMtx = data.inputValue(node.reader).asFloathMatrix()
targetMtx = data.inputValue(node.target).asFloathMatrix()
result = readerMtx * targetMtx
outputHandle = data.outputValue(node.Moutput)
outputHandle.setMFloatMatrix(result)
data.setClean(plug)
def initializer():
mtxAttr1 = OpenMaya.MFnMatrixAttribute()
node.reader = mtxAttr1.create("In_Matrix","reader",OpenMaya.MFnMatrixData.kMatrix)
mtxAttr1.setKeyable = True
mtxAttr1.setStorable = True
mtxAttr1.Readable = True
mtxAttr1.setWrit = True
mtxAttr2 = OpenMaya.MFnMatrixAttribute()
node.Target = mtxAttr2.create("Target_Matrix","reader",OpenMaya.MFnMatrixData.kMatrix)
mtxAttr2.setKeyable = True
mtxAttr2.setStorable = True
mtxAttr2.Readable = True
mtxAttr2.setWrit = True
mtxAttr3 = OpenMaya.MFnMatrixAttribute()
node.MOutput = mtxAttr3.create("In_Matrix","Moutput",OpenMaya.MFnMatrixData.kMatrix)
mtxAttr3.writable = True
mtxAttr3.keyable = True
node.addAttribute(node.reader)
node.addAttribute(node.Target)
node.addAttribute(node.MOutput)
node.AttributeAffects(node.reader , node.MOutput)
node.AttributeAffects(node.Target , node.MOutput)
Help me a lot!
I'm trying to create a system for pattern matching in images and this is what I have currently:
def ratio(x,y):
return 1/(x*y)
def memory(image):
i__ia=0
l__img = Image.open(image)
l__pix = l__img.load()
l__width = l__img.width
l__height = l__img.height
s__img = None
l__r = 0
l__b = 0
l__g = 0
s__str = None
s__per = 0
for filename in os.listdir("Memory/"):
i__ia+=1
m__percent = 0
p__r = 0
p__g = 0
p__b = 0
f = os.path.join("Memory/", filename)
m__img = Image.open(f)
m__pix = m__img.load()
for l__w in range(0,l__width,1):
for l__h in range(0,l__height,1):
try:
if m__pix[l__w,l__h] == l__pix[l__w,l__h]:
temp = m__pix[l__w,l__h]
a__percent = ratio(l__width,l__height)
p__r+=temp[0]
p__g+=temp[1]
p__b+=temp[2]
m__percent+=a__percent
else:
p__r+=temp[0]
p__g+=temp[1]
p__b+=temp[2]
a__percent = ratio(l__width,l__height)
m__percent-=a__percent
except:
a__percent = ratio(l__width,l__height)
m__percent-=a__percent
pass
if m__percent > s__per and p__r >= l__r and p__b >= l__b and p__g >= l__g:
s__per = m__percent
s__img = m__img
s__str = f
l__r = (1/(p__r+p__b+p__g))*p__r
l__b = (1/(p__r+p__b+p__g))*p__b
l__g = (1/(p__r+p__b+p__g))*p__g
else:
m__percent = 0
if s__per > 0.8:
return True, s__per, s__str,l__r,l__g,l__b
else:
try:
tes = Image.open(image)
tes.save(f'Memory/unknown{i__ia}.png')
return False, s__per, s__str,l__r,l__g,l__b
except:
pass
My end goal is to find differences between pictures, find similarities, be able to classify the image based on how similar it is to other images.
Currently, all I've made is something that can tell how similar two images are based on their color differences and size differences.
I'm having trouble thinking of a way to detect if there is a similar shape or pattern in the image.
Any help is greatly appreciated!
I am looking for the cleanest way to declare multiple variables in Python. My code looks like this:
app_type = config_data["app"]
app_params = config_data["app_data"]
original_fps = config_data["main"][0]["original_fps"]
sub_sampled_fps = config_data["main"][0]["sub_sampled_fps"]
max_retries = config_data["main"][0]["max_retries"]
win_size = config_data["main"][0]["window_size"]
input_frame_rate = config_data["main"][0]["input_frame_rate"]
Is something like this acceptable by the styling guide?
app_type = config_data["app"]
app_params = config_data["app_data"]
original_fps = config_data["main"][0]["original_fps"]
sub_sampled_fps = config_data["main"][0]["sub_sampled_fps"]
max_retries = config_data["main"][0]["max_retries"]
win_size = config_data["main"][0]["window_size"]
input_frame_rate = config_data["main"][0]["input_frame_rate"]
If not are there any better ways to style it?
Not recommended according to pep8:
# Correct:
x = 1
y = 2
long_variable = 3
# Wrong:
x = 1
y = 2
long_variable = 3
See the reference here
How to I create a 3 level list in python 2.7? See Image of Nested Lists HERE
Setup:
I have the following inputs:
Files(s)
Categories
I then Search through each file, and iterate through each category to get every Value.
I just can't get the desired output.
# Combine Multiple Lists
LinkDoc = ["File1", "File2", "File3"]
cat = ["Walls", "Doors", "Columns"]
rvt1_wall = ["W1_rvt1", "W2_rvt1"]
rvt1_door = ["D1_rvt1", "D2_rvt1", "D3_rvt1", "D4_rvt1"]
rvt1_col = ["C1_rvt1"]
rvt2_wall = ["W2_rvt2", "W2_rvt2"]
rvt2_door = ["D2_rvt2", "D2_rvt2", "D3_rvt2", "D4_rvt2"]
rvt2_col = ["C2_rvt2"]
rvt3_wall = ["W3_rvt3", "W2_rvt3"]
rvt3_door = ["D3_rvt3", "D2_rvt3", "D3_rvt3", "D4_rvt3"]
rvt3_col = ["C3_rvt3"]
rvt4_wall = ["W4_rvt4", "W2_rvt4"]
rvt4_door = ["D4_rvt4", "D2_rvt4", "D3_rvt4", "D4_rvt4"]
rvt4_col = ["C4_rvt4"]
all_comb1 = [rvt1_wall,rvt1_door,rvt1_col]
all_comb2 = [rvt2_wall,rvt2_door,rvt2_col]
all_comb3 = [rvt3_wall,rvt3_door,rvt3_col]
all_comb4 = [rvt4_wall,rvt4_door,rvt4_col]
all_tot = [all_comb1, all_comb2, all_comb3, all_comb4]
xyz_pairs = [[x,y,z] for x in LinkDoc for y in cat for z in all_tot]
print(xyz_pairs)
print("========")
print("")
pt1 = Point(280,49)
pt2 = Point(279,62)
pt3 = Point(276,86)
pt4 = Point(274,114)
pt5 = Point(273,126)
pt6 = Point(271,153)
pt7 = Point(269,166)
pt8 = Point(268,179)
pt9 = Point(267,192)
pt10 = Point(266,206)
pt11 = Point(265,213)
pt12 = Point(264,223)
pt13 = Point(264,230)
pt14 = Point(262,238)
pt15 = Point(256,238)
pt16 = Point(244,238)
pt17 = Point(235,239)
pt18 = Point(226,238)
pt19 = Point(223,236)
pt20 = Point(226,222)
ferb = Polygon (pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8,pt9,pt10,pt11,pt12,pt13,pt14,pt15,pt16,pt17,pt18,pt19,pt20).
This is my code and I need I way to rewrite this using loops in python. I have to use either for or while loop, oh and conditional statements(if and elif) if neccessary