Forum Archive

Cannot assign string to object in ui

cjohnson32

Hi all,

I’m extremely new to python and coding in general. I am trying to create a fairly simple app to clock in and out for work purposes. I have the ui show my “time card” which I want to have a running digital clock at the top of the screen. I can get the time and have it update every second but am having issues sending the string to an (any) object in my ui. Perhaps I’m not using the correct object to display my string or not using the correct code to send it. The error I keep getting is “ui.View” object does not support item assignment. My code looks something like this:

```
import ui
import time

def change_view(sender):
'@type sender: ui.Button'
#get button name:
b = sender.name
v = ui.load_view(b)
return v.present()

@ui.in_background
def update_time():
while True:
time.sleep(1)
v1['clock_view'] = time.strftime('%r')

v1 = ui.load_view('time_card')
update_view()
v1.present() ```

cvp

@cjohnson32 As we don't see the ui file, I'll suppose, as example, that your object named clock_view is an ui.Label where you want to display the time. Thus you have to store the string in the right attribute, in this case "text", thus you have to type

v1['clock_view'].text = time.strftime('%r')
cjohnson32

@cvp that was exactly what I needed. I thought label is what should be used but had no success sending my string. Turns out I was only missing the .text - Thank you!

natelive

Retrieve additional comments omitted from a base comment tree.

When a comment tree is rendered, the most relevant comments are selected for display first. Remaining comments are stubbed out with "MoreComments" links. This API call is used to retrieve the additional comments represented by those stubs, up to 100 at a time.

The two core parameters required are link and children. link is the fullname of the link whose comments are being fetched. children is a comma-delimited list of comment ID36s that need to be fetched.

If id is passed, it should be the ID of the MoreComments object this call is replacing. This is needed only for the HTML UI's purposes and is optional otherwise.

NOTE: you may only make one request at a time to this API endpoint. Higher concurrency will result in an error being returned.

If limit_children is True, only return the children requested.

depth is the maximum depth of subtrees in the thread.