I'm working on a shopping cart GUI. I have a list called my_order, which stores the information I get from the user. I want to update label text in a for loop so I can print all the elements of my_order list. Here's my code:
class PaymentScreen(QMainWindow):
def __init__(self):
super(PaymentScreen, self).__init__()
loadUi("paymentscreen.ui",self)
self.gobackbutton.clicked.connect(self.goback)
self.basket.setText("{}".format(my_order)) #the output looks like ["burger","fries"] and I dont want that
I'm trying to print all the elements one under the another instead of that list view. I looked for the similar cases but couldn't find the solution.
I want the output to look like this:
burger
fries
How can I do that?
I want to update label text
I am no expert in Python GUI but i am good in python programming and I assume you want the string inside setText to be a multiline string. I could help with that.
You can use something line this:
self.basket.setText("\n".join(my_order))
Related
I want to make text bold work as intended, meaning for example when you want to make a selected word bold, but you mistakenly didn't select the whole word, and you left out the last letter, and then you want to correct that mistake and select the whole word, instead of bolding the word, it will change its weight to normal. Specifically I'm talking about this way of doing this:
`
def bold_it():
bold_font = font.Font(my_text, my_text.cget("font"))
bold_font.configure(weight="bold")
my_text.tag_configure("bold", font=bold_font)
current_tags = my_text.tag_names("sel.first")
if "bold" in current_tags:
my_text.tag_remove("bold", "sel.first", "sel.last")
else:
my_text.tag_add("bold", "sel.first", "sel.last")
`
I am fully aware of what the problem is, and it is in the current_tags variable, since the variable will return "bold" because tag names only looks at tags which are at the first selected position. In turn, this will make the if statements remove the bold tag instead of applying it.
So my question is, how do you fix this, or optimize this?
Codemy.com did a video on this, and this question is based on this video, https://www.youtube.com/watch?v=X6zqePBPDVU.
I tried utilizing the tag_ranges() method so I could get two indexes instead of just where the selecting begins, but it did not work because tag_names() accepts only one argument.
I have a Python output in a Zapier output that looks like this:
I want to be able to use this in the body of gmail as separate lines. However, presently, it looks like this when I use that python output as the step. The screenshot below is the email returned after I test.
Is there a filter or a pythonic way to do this within Zapier?
The output would ideally look like this:
https://hectv.sharefile.com/dxxxxxxxfcebd247d09
https://hectv.sharefile.com/dxxxxxxx729cd9494
https://hectv.sharefile.com/d-xxxxxx84622a
Thank you.
William from Zapier answered this for me.
If we're generating a line item array with the code step and we need individual items, you'll want to add a Formatter - Utility - Line Item to Text action.
This action will go just after the Run Python step and should take the Sharefile Output as the input for the formatter. From there, the formatter can break the line item array down into individual text strings that you can assign in the zaps remaining steps. :)
For more information on Formatter check out our article here: https://zapier.com/help/create/format/get-started-with-formatter
For more info on Line Item to Text, check out this article: https://zapier.com/help/create/format/convert-line-items-into-text-strings
Using Line Item to Text, the zap won't care if there are 10 items or a single item, it should still return the same individual items. The main concern there is that the test that is done with Line Item to Text should be a test that include the MAX number of items. This way those items can be assigned in the following steps and used when they're present or ignored when they are not.
This is part of my code, the id of image wont print even I use the withtag function. I think the function canvas.delete won't work is also the same problem, it seem the tag is inserted as "123","456". However, the tag I expected to use and get is 123 instead of '123'. And I guess it's the main problem I can't get the id I want with the findtag function.
CurrentImage=Note[NoteIndexLocal]
Temp=canvas.create_image(XShow,YShow,image=CurrentImage,tag=123)
print canvas.find_withtag(123) #This Wont Work,printed()
canvas.delete(123) #This Wont Work
print canvas.gettags(Temp) #printed '123'
From: http://effbot.org/tkinterbook/canvas.htm
Tags are symbolic names attached to items. Tags are ordinary strings,
and they can contain anything except whitespace (as long as they don’t
look like item handles).
Use str(123) instead of 123
EDIT: correct answer is in text from doc "as long as they don’t look like item handles". Number 123 looks like item handle (print Temp to see how it looks like) so it doesn't work. Use text like "a123" and it will work.
I have created a listctrl with some of the data in the listctrl are very long, and instead of showing all of the text it ends with .... For example Att PSSM_r1_0_T is [-10.179077,0.944198]|Att PSSM_r1_0_Y is.... How would i be able to make it so it shows all of the text. Something like
Att PSSM_r1_0_T is [-10.179077,0.944198]|Att PSSM_r1_0_Y is
[-4.820935,9.914433]|Att PSSM_r1_2_I is [-8.527803,1.953804]|Att PSSM_r1_2_K is [-12.083334,-0.183813]|Att PSSM_r1_2_V is
[-14.112536,5.857771]|1
As the text is very long I would prefer if it covered more than one line.
I don't think that is possible to do with a standard listctrl.
Try poking around at the UltimateListCtrl, being a full owner drawn listctrl it has the ability to change the way its looks far more than a standard listctrl.
I have a text widget in my python Tkinter script and i am trying to get the value that the user enter. My intention is to write the data from the text widget together with other values from the script(ie. x,y,z) to the txt file(faultlog.txt) as a single line with semi-column separated. This is what i tried.
...
text=Text(width=30,height=1)
text.place(x=15,y=75)
data=text.get(1.0,END)
lines=[]
lines.append('{};{};{};{} \n'.format(data,x,y,z))
faultlog=open("faultlog","a")
faultlog.writelines(lines)
faultlog.close()
...
Instead of giving me a single line output in the text file, python is writing this to the txt file (assuming the data that user enter is "abcdefgh")
abcdefgh
;x;y;z
just to make things clear, this is what i want
abcdefgh;x;y;z
What did i do wrong? I hope the question is clear enough, i am a beginner so please make the answer simple.
When you get all text of the widget, there is also included a "\n" at the end. You can remove this last character like this:
data=text.get(1.0,END)[:-1]
Note that this always works independently of the length of the text length:
>>> "\n"[:-1]
''
>>> ""[:-1]
''