sugarlabs / typing-turtle-activity

A typing tutor for the sugar learning environment
GNU General Public License v3.0
4 stars 8 forks source link

Port to Python3 + GTK3 Fix + Some GTK3 Deprecation Fixes [GCI] #11

Closed srevinsaju closed 4 years ago

srevinsaju commented 4 years ago

These are some of the fixes to port to python3 activity.info sugar-activity has been changes to sugar-activity3 wrt GCI

quozl commented 4 years ago

Thanks. I checked out 1c3423e on Ubuntu 19.04 with Sugar 0.116 and ran it as an activity. It didn't start, and logs had a TypeError. I checked out master branch and ran it, and it did work. Please fix.

srevinsaju commented 4 years ago

@quozl can you please share the log message, if possible. that will do a great help to me :)

quozl commented 4 years ago
/usr/share/sugar/activities/TypingTurtle.activity/typingturtle.py:32: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk
/usr/share/sugar/activities/TypingTurtle.activity/typingturtle.py:54: PyGIWarning: PangoCairo was imported without specifying a version first. Use gi.require_version('PangoCairo', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import PangoCairo
Traceback (most recent call last):
  File "/usr/bin/sugar-activity3", line 5, in <module>
    activityinstance.main()
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/activityinstance.py", line 230, in main
    instance = create_activity_instance(activity_constructor, activity_handle)
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/activityinstance.py", line 59, in create_activity_instance
    activity = constructor(handle)
  File "/usr/share/sugar/activities/TypingTurtle.activity/typingturtle.py", line 105, in __init__
    self.mainscreen = mainscreen.MainScreen(self)
  File "/usr/share/sugar/activities/TypingTurtle.activity/mainscreen.py", line 105, in __init__
    self.lessons.sort(lambda x, y: x.get('order', 0) - y.get('order', 0))
TypeError: sort() takes no positional arguments
quozl commented 4 years ago

You might also check to see why you didn't get the same message; is there something you haven't pushed to the branch, something you haven't committed, or different version of Python? Mysteries can bite later.

srevinsaju commented 4 years ago

@quozl I had forgotten to push the commit which I made in sugar .iso while testing. persistent reboots are causing the delay, hence I haven't tested this commit, hopefully I haven't missed anything else.

same version of python 3.7 😅

quozl commented 4 years ago

I checked out 2021dda and tried again, but got an error. Am I doing something wrong?

Traceback (most recent call last): ...
  File "/usr/share/sugar/activities/TypingTurtle.activity/typingturtle.py", line 105, in __init__
    self.mainscreen = mainscreen.MainScreen(self)
  File "/usr/share/sugar/activities/TypingTurtle.activity/mainscreen.py", line 105, in __init__
    self.lessons.sort(key=lambda x, y: x.get('order', 0) - y.get('order', 0))
TypeError: <lambda>() missing 1 required positional argument: 'y'

If it helps, here are the md5sums of the source files.

602a010838d736647b95a452acfe66d2  balloongame.py
543f55516050391ded3b4faa73cfc196  editlessonlistscreen.py
94b571a9673b69e603f741d336ea76fb  editlessonscreen.py
6d456f55b854289b2414b083d4eb99e6  keyboard.py
395bce2aea6ff3800153bb24852d4cec  keybuilder.py
b56d07dcaf537799a623272572ab6c3f  lessonbuilder.py
f95abc55d1a000ff2e40e507c5565f76  lessonscreen.py
523ffa4668d140030f086855965917bc  mainscreen.py
cf5a3e35fa0c600c207cc1fca28962b7  medalscreen.py
7636dafcfb89d5b66a9d17f675677732  setup.py
c2eee0f6e1d20489162538d9677698ae  titlescene.py
f86f9111e79197816e0394d1d796f7b1  typingturtle.py
srevinsaju commented 4 years ago

I will check it @ 1400 GMT+300

srevinsaju commented 4 years ago

@quozl I have fixed the errors. Switched to Fedora, sugar's working fine! I have changed the scripts functions now to a new method. Initially sort was used. Now sort is replaced by sorted. Other GTK 3 Errors along with a byte error Fixed

srevinsaju commented 4 years ago

@chimosky, fixed that, it was used for debugging

quozl commented 4 years ago

Fixes https://github.com/sugarlabs/typing-turtle-activity/issues/10

quozl commented 4 years ago

Thanks. Reviewed. Some minor things to fix which I was prepared to do myself; such as unnecessary new comments. But when I tested I hit a problem with "Start lesson";

Traceback (most recent call last):
  File "/usr/share/sugar/activities/TypingTurtle.activity/mainscreen.py", line 262, in lesson_clicked_cb
    self.activity.push_screen(lessonscreen.LessonScreen(self.visible_lesson, self.keyboard_images, self.activity))
  File "/usr/share/sugar/activities/TypingTurtle.activity/lessonscreen.py", line 155, in __init__
    self.begin_lesson()
  File "/usr/share/sugar/activities/TypingTurtle.activity/lessonscreen.py", line 213, in begin_lesson
    self.advance_step()
  File "/usr/share/sugar/activities/TypingTurtle.activity/lessonscreen.py", line 337, in advance_step
    self.begin_line()
  File "/usr/share/sugar/activities/TypingTurtle.activity/lessonscreen.py", line 345, in begin_line
    self.hilite_next_key()
  File "/usr/share/sugar/activities/TypingTurtle.activity/lessonscreen.py", line 539, in hilite_next_key
    pixbuf = self.keyboard.get_key_pixbuf(key, state, group, 1)
  File "/usr/share/sugar/activities/TypingTurtle.activity/keyboard.py", line 582, in get_key_pixbuf
    surface.write_to_png(pixbuf_data)
keyboard.IOError: error while writing to output stream
srevinsaju commented 4 years ago

@quozl I fixed it all at last, took an hour :cry:

srevinsaju commented 4 years ago

@quozl The io.String had to be changed to io.Bytes, causing a whole lot of issues, the typing lessons didn't work because of that

quozl commented 4 years ago

Thanks. Improved. I'm getting new errors;

Traceback (most recent call last):
  File "/usr/share/sugar/activities/TypingTurtle.activity/lessonscreen.py", line 382, in key_cb
    self.advance_step()
  File "/usr/share/sugar/activities/TypingTurtle.activity/lessonscreen.py", line 324, in advance_step
    self.lessonbuffer.get_end_iter(), l.encode('utf-8') + '\n', 'text')
TypeError: can't concat str to bytes
Traceback (most recent call last):
  File "/usr/share/sugar/activities/TypingTurtle.activity/lessonscreen.py", line 426, in key_cb
    if key == self.line[self.char_idx]:
TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/share/sugar/activities/TypingTurtle.activity/lessonscreen.py", line 426, in key_cb
    if key == self.line[self.char_idx]:
TypeError: 'NoneType' object is not subscriptable

Please test?

srevinsaju commented 4 years ago

@quozl how to recreate the error?

quozl commented 4 years ago

I don't know. From memory it was semi-random testing of some of the lessons or the user interface.

quozl commented 4 years ago

Fixes https://github.com/sugarlabs/typing-turtle-activity/issues/10

srevinsaju commented 4 years ago

@quozl, I fixed most bugs with this https://github.com/sugarlabs/typing-turtle-activity/pull/11/commits/19cbb4a6a2dcc3dbf54608a0987666b8a2f331ba . Its the maximum I could discove, fixed all the errors I could find :100: