How to fill the internet form - find

I am trying to fill the adress form (delivery address), but can't fill Flat Number. Part wit City/Street/House number is working correctly, but FlatNumber is just nothing.
input_tab = browser.find_element(By.XPATH, '//*[#id="addressQueryInput"]')
input_tab.send_keys("City, street, house")
input_tab_f = browser.find_element(By.XPATH, '//*[#id="inputFlatNumber"]')
input_tab_f.send_keys(Keys.ENTER)
input_tab_f.send_keys("12")

Related

Unmerge and Assign Values Only Vertically or Horizontally Openpyxl

Using the answer provided by aka863 here: How to split merged Excel cells with Python?
I can unmerge, fill values and copy the styling. My questions is how to make the value assigning/filling process configurable.
I want the user to be able to choose whether the values will be filled vertically/horizontally.
I have tried changing the last loop where we assign the top_left_cell_values to unmerged cells. However I couldn't find a way to make it horizontal/vertical configurable. (I'm planning to use radio buttons and tkinter for this)
Its certainly possible to have the code de-merge cells and fill cells in whichever direction, vertically or horizontally regardless of which way the merge was originally. Or not fill at all, so only the top left cell retains the 'value' of the previously merged cells, which is default on unmerge.
Changing the direction of the fill requires some change and re-calculation on the max row and column values in the iter_rows loop, but is simple enough.
However it seems in your last comment you just want to give the user the option to fill or not fill on horizontal merges. In that case you just need to ask the question, and then run the iter_rows loop only if the response is yes.
The code sample below is based on the answer referenced question.
I'm assuming only single line horizontal merges since you dont mention what if anything should be done with vertical merges in the comment.
The code does initially check and indicate the merge direction either vertically or horizontally so it can be included take some action if a merge is vertical.
On code run after displaying the range and direction of the merge, the question is asked to fill, yes or no. If yes the cells are de-merged and all cells filled with the top left cell value using the iter_rows loop. If answer no then the cells are just de-merged.
from openpyxl import load_workbook
from openpyxl.utils.cell import range_boundaries
wb = load_workbook(filename='foo.xlsx')
st = wb['Sheet1']
mcr_coord_list = [mcr.coord for mcr in st.merged_cells.ranges]
direction_dict = {'v': 'vertical', 'h': 'horizontal'}
for mcr in mcr_coord_list:
print('---------------------------------------------------\n')
merge_direction = ''
min_col, min_row, max_col, max_row = range_boundaries(mcr)
top_left_cell_value = st.cell(row=min_row, column=min_col).value
if min_col == max_col:
merge_direction = 'v'
elif min_row == max_row:
merge_direction = 'h'
print(f"The cell range {mcr} is merged {direction_dict[merge_direction]}ly with the data '{top_left_cell_value}'")
while True:
demerge_fill = input('Do you want the de-merge to fill all cells(y|n)? ')
if demerge_fill.lower() in ["y", "n"]:
break
else:
print('Invalid response')
st.unmerge_cells(mcr)
if demerge_fill == 'y':
for row in st.iter_rows(min_col=min_col, min_row=min_row, max_col=max_col, max_row=max_row):
for cell in row:
cell.value = top_left_cell_value
else:
print(f"Only the top left cell {mcr.split(':')[0]} will contain the data!")
wb.save('merged_tmp.xlsx')

Document generator, different margins for certain pages

I am creating a document using MATLAB's mlreportgen.dom.*;
I would like to be able to set the first and last page of a document to have no margins. This way I can get images to fit right across the page.
I am having difficulties with this, see example code
import mlreportgen.dom.*;
d = Document('myreport', 'pdf');
open(d);
currentLayout = d.CurrentPageLayout;
pdfheader = PDFPageHeader();
p = Paragraph('Sample Traffic Data in Austin');
p.Style = [p.Style, {HAlign('left'), Bold(true), FontSize('12pt')}];
append(pdfheader, p);
currentLayout.PageHeaders = pdfheader;
currentLayout.PageMargins.Gutter = '0.0in';
currentLayout.PageMargins.Left = '0.0in';
currentLayout.PageMargins.Right = '0.0in';
close(d);
rptview(d.OutputPath);
So far, I have naively tried to add a page break and redefine margins with no success. It appears to use the margins that come last in the document.

Access VBA to Change an Image in a Continuous Form

I am trying to create a receipt form where people will confirm if they've received the full quantity of an order. As part of this, I want the following to happen:
If they received the full quantity, a green check mark appears
If they received a partial quantity, an orange triangle appears
If they received no items, a red x appears
To accomplish this, I'm using a continuous form with 3 image files for each situation. I'm using the code below to change the image when the quantity is changed. The problem is, when the quantity is change on 1 line, the symbol changes for all lines. I'll post pictures as well.
Any thoughts on how I can fix this?
I'm open to other methods of accomplishing this idea too.
Private Sub FinalQTY_AfterUpdate()
If IsNull(Me.FinalQty) Then
MsgBox "You must enter a quantity for this item"
Me.FinalQty.SetFocus
Exit Sub
Else
LValue = Me.[FinalQty]
If IsNumeric(LValue) = 0 Then
Me.FinalQty = ""
MsgBox "Qty must be a numeric value"
Me.QTY.SetFocus
Exit Sub
End If
End If
Me.FinalTotalPrice = Me.FinalPrice * Me.FinalQty
If Me.FinalQty = 0 Then
Me.Yes.Visible = False
Me.Change.Visible = False
Me.No.Visible = True
End If
If Me.FinalQty < Me.QTY Then
Me.Yes.Visible = False
Me.Change.Visible = True
Me.No.Visible = False
End If
If Me.FinalQty = Me.QTY Then
Me.Yes.Visible = True
Me.Change.Visible = False
Me.No.Visible = False
End If
End Sub
This is before I adjust the quantity:
This is after I adjust the qty of only the second line:
Since the formatting of each record displayed by a continuous form is inherited from the form design template, any changes to the template will be automatically applied to all records displayed by the form, aside from Conditional Formatting rules in effect or the handful of properties which may changed via the OnPaint event of the Detail section.
One possible alternative might be to add a new field to your table with a data type of OLE Object and populate the value on the AfterUpdate event using the AppendChunk method, sourcing image data from a separate table containing three records corresponding to your green tick, orange triangle, and red cross images.

Output additional Text in Powermail if specific Checkbox is checked

so here's my problem: I tried to output an additional text once a specific checkbox is checked in powermail.
The select field contains multiple options and all are selectable of course, but when i.e. field 1 is checked the sender should have the standard text in the mail plus "Lorem ipsum", but when the field isn't checked there should be no additional output at all.
I could find a solution for altering texts depending on a selection for single selects / dropdowns and it works like a charm, but for a reason the multi-select doesn't work at all. I can't figure out why so maybe someone can help.
TS:
lib.serverex = CASE
lib.serverex {
key.data = GP:tx_powermail_pi1|field|produktang|1
key.intval = 1
1 = TEXT
1.value = Lorem Ipsum
#Default
default = TEXT
default.value =
}
The email in powermail looks like this:
Some standard text...
{f:cObject(typoscriptObjectPath:'lib.serverex', data:'{produktang}')}
The checkbox configuration inside the form (id: produktang):
first product | 1
second product | 2
third product | 3
fourth product | 4
fifth product | 5
Either it appends it no matter what the input is/checked boxes are or it doesn't send the additional text at all. I'm probably missing something here.
Thanks in advance!
The result of field {produktang} is an array (of course because it's a checkbox). So you have to find out if there is any key with value "2" (e.g. if you're searching for product 2) of in your case tx_powermail_pi1|field|produktang|1 == 2
I solved it now with kind of a trick because I couldn't make it work in a different way.
What I did:
I moved the specific product where the email alters to the first position in the multiselect element. So it's Index will be 0.
The next thing is to check if the element in position 0 of the array equals the desired product, in my case it's "firstProduct". Since it's in the first position it'll always be "firstProduct" if "firstProduct" is checked and the additional text will be "printed". I set the default text to an empty string so it'll stay blank in every other case.
Here's the code:
lib.serverex = CASE
lib.serverex {
key.data = GP:tx_powermail_pi1|field|produkt|0
firstProduct = TEXT
firstProduct.value = Lorem Ipsum
#Default
default = TEXT
default.value =
}
The configuration of the Checkbox inside powermail:
firstProduct
secondProduct
thirdProduct
fourthProduct
fifthProduct
And the code which is inside of the email itself:
{f:cObject(typoscriptObjectPath:'lib.serverex', data:'{produkt}')}
It probably works in another way as well, but I couldn't solve it another way. Hope this helps if someone encounters the same issues I had.

Setting up some properties for a combobox (scroll, edit, jump)

There are 3 properties that I want to set for some VBA form comboboxes and I don't know if it's possible.
I don't want to let the combobox editable. Right now if the user types something in it that it submits the form it will send that value... I want to let him choose only from the values I added in the Combobox.
I want to make the list of items in the combobox scroll-able. Right now I'm able to scroll through the list if I use the scroll-bar but I don't know why I can't scroll with the mouse scroll.
And I want to jump to some item if I start typing. Let's say I have the months of the year in one combobox... if I start to type mar I want it to jump to march. I know that for the html forms this properties is by default but I don't know about VBA forms...
Thanks a lot
Of the behaviours you want, some are possible with settings on the Combo, others you will need to code
List of Months: Put a list of entries on a (hidden) sheet and name the range. Set .RowSource to that range
Match as you type: Set properties .MatchEntry = fmMatchEntryComplete and .MatchRequired = True
Reject non list entries: A Combo with these settings will allow you to type an invalid entry, but will reject it with an error message popup when you commit. If you want to silently reject invalid data as you type, you will need to code it.
If you want the selected value returned to a sheet, set .ControlSource to a cell address (preferable a named range)
By "...scroll with the mouse scroll..." I assume you mean the mouse wheel. Unfortunatley Forms don't support mouse wheel scroll. You will have to code it yourself. There is a Microsoft patch for this at here (not tried it myself yet)
Sample code to silently reject invalid entries
Private Sub cmbMonth_Change()
Static idx As Long
Dim Match As Boolean
Dim i As Long
If cmbMonth.Value = "" Then Exit Sub
If idx = 0 Then idx = 1
i = idx
Match = False
For i = 0 To cmbMonth.ListCount
If cmbMonth.List((i + idx - 1) Mod cmbMonth.ListCount) Like cmbMonth.Value & "*" Then
cmbMonth.ListIndex = (i + idx - 1) Mod cmbMonth.ListCount
Match = True
Exit For
End If
Next
If Not Match Then
cmbMonth.Value = Left(cmbMonth.Value, Len(cmbMonth.Value) - 1)
End If
End Sub
Set the propertie MatchEntry of combobox to 1 (fmMatchEntryComplete) and MatchRequired to true for example
combobox1.MatchEntry=1
combobox1.MatchRequired=True
[]'s