Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
interface
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
homeostasis
interface
Commits
90e72932
Commit
90e72932
authored
10 years ago
by
Benoit Favre
Browse files
Options
Downloads
Patches
Plain Diff
add viewer for source code
parent
bffa8703
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sourceview.py
+68
-0
68 additions, 0 deletions
sourceview.py
with
68 additions
and
0 deletions
sourceview.py
0 → 100755
+
68
−
0
View file @
90e72932
#!/usr/bin/env python2
import
sys
import
os
# set to location of libgstkaldionline2.so
os
.
environ
[
'
GST_PLUGIN_PATH
'
]
=
'
./asr/
'
os
.
environ
[
'
GTK_THEME
'
]
=
'
light
'
# import gtk stuff
from
threading
import
Thread
import
gi
gi
.
require_version
(
'
Gst
'
,
'
1.0
'
)
from
gi.repository
import
GObject
,
Gst
,
Gtk
,
Gdk
,
GtkSource
GObject
.
threads_init
()
Gdk
.
threads_init
()
Gst
.
init
(
None
)
# make sure ctrl-c works
import
signal
signal
.
signal
(
signal
.
SIGINT
,
signal
.
SIG_DFL
)
# import local stuff
import
asr
class
SourceView
(
Gtk
.
Window
):
def
__init__
(
self
,
asr_config_file
):
super
(
SourceView
,
self
).
__init__
()
self
.
connect
(
"
destroy
"
,
self
.
quit
)
self
.
set_default_size
(
800
,
600
)
self
.
set_border_width
(
10
)
self
.
set_title
(
'
SourceView
'
)
vbox
=
Gtk
.
VBox
()
self
.
source_buffer
=
GtkSource
.
Buffer
()
lang_manager
=
GtkSource
.
LanguageManager
()
self
.
source_buffer
.
set_language
(
lang_manager
.
get_language
(
'
python
'
))
self
.
source_buffer
.
set_text
(
open
(
__file__
).
read
())
self
.
source_view
=
GtkSource
.
View
.
new_with_buffer
(
self
.
source_buffer
)
self
.
source_view
.
set_show_line_numbers
(
True
)
self
.
source_view
.
set_tab_width
(
4
)
self
.
scrolled
=
Gtk
.
ScrolledWindow
()
self
.
scrolled
.
add
(
self
.
source_view
)
vbox
.
pack_start
(
self
.
scrolled
,
True
,
True
,
5
)
self
.
asr
=
asr
.
ASR
(
asr_config_file
,
self
.
hyp_changed
)
vbox
.
pack_start
(
self
.
asr
,
False
,
True
,
5
)
self
.
add
(
vbox
)
self
.
show_all
()
# load css style
style_provider
=
Gtk
.
CssProvider
()
style_provider
.
load_from_data
(
open
(
'
data/style.css
'
,
'
rb
'
).
read
())
Gtk
.
StyleContext
.
add_provider_for_screen
(
Gdk
.
Screen
.
get_default
(),
style_provider
,
Gtk
.
STYLE_PROVIDER_PRIORITY_APPLICATION
)
def
hyp_changed
(
self
,
hyp
):
pass
def
quit
(
self
,
window
):
Gtk
.
main_quit
()
if
__name__
==
'
__main__
'
:
asr_config_file
=
'
asr/fisher-benoit-1.cfg
'
app
=
SourceView
(
asr_config_file
)
Gtk
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment