Running gstreamer on ubuntu sending video through RTSP is too slow - gstreamer
I am trying to stream live video from a webcam attached on my ubuntu machine.
I first checked out the gst-rtsp-server code and followed the steps below:
$ git clone git://anongit.freedesktop.org/gstreamer/gst-rtsp-server
$ cd gst-rtsp-server
$ git checkout 1.4
$ ./autogen.sh
$ make
$ sudo make install
Then I tried to send the test pattern image
./test-launch '( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )'
stream ready at rtsp://127.0.0.1:8554/test
The client side can see the pattern - works.
Then I tried to display the webcam with the following command.
./test-launch '( v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=30/1 ! videoconvert ! x264enc ! rtph264pay name=pay0 pt=96 )'
This works fine but the latency is about 3 seconds.
Is there a way to reduce the latency to make it look more like in real time ?
From gst-device-monitor I see the following message:
$ gst-device-monitor-1.0
Probing devices...
Device found:
Analog Stereo: BUFFALO BSWHD06M USB Camera
class : Audio/Source
caps : audio/x-raw, format=(string){ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, S24LE, S24BE, S24_32LE, S24_32BE, U8 }, layout=(string)interleaved, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-alaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-mulaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
properties:
alsa.resolution_bits = 16
device.api = alsa
device.class = sound
alsa.class = generic
alsa.subclass = generic-mix
alsa.name = "USB\ Audio"
alsa.id = "USB\ Audio"
alsa.subdevice = 0
alsa.subdevice_name = "subdevice\ \#0"
alsa.device = 0
alsa.card = 1
alsa.card_name = "BUFFALO\ BSWHD06M\ USB\ Camera"
alsa.long_card_name = "KYE\ Systems\ Corp.\ BUFFALO\ BSWHD06M\ USB\ Camera\ at\ usb-0000:00:14.0-10\,\ high\ spee"
alsa.driver_name = snd_usb_audio
device.bus_path = pci-0000:00:14.0-usb-0:10:1.2
sysfs.path = /devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10:1.2/sound/card1
udev.id = usb-KYE_Systems_Corp._BUFFALO_BSWHD06M_USB_Camera-02
device.bus = usb
device.vendor.id = 0411
device.vendor.name = "BUFFALO\ INC.\ \(formerly\ MelCo.\,\ Inc.\)"
device.product.id = 0260
device.product.name = "BUFFALO\ BSWHD06M\ USB\ Camera\015"
device.serial = KYE_Systems_Corp._BUFFALO_BSWHD06M_USB_Camera
device.form_factor = webcam
device.string = front:1
device.buffering.buffer_size = 352800
device.buffering.fragment_size = 176400
device.access_mode = mmap+timer
device.profile.name = analog-stereo
device.profile.description = "Analog\ Stereo"
device.description = "BUFFALO\ BSWHD06M\ USB\ Camera\015\ Analog\ Stereo"
module-udev-detect.discovered = 1
device.icon_name = camera-web-usb
is-default = true
gst-launch-1.0 pulsesrc device=alsa_input.usb-KYE_Systems_Corp._BUFFALO_BSWHD06M_USB_Camera-02.analog-stereo ! ...
Device found:
name : Monitor of Built-in Audio Digital Stereo (HDMI 3)
class : Audio/Source
caps : audio/x-raw, format=(string){ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, S24LE, S24BE, S24_32LE, S24_32BE, U8 }, layout=(string)interleaved, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-alaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-mulaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
properties:
device.description = "Monitor\ of\ Built-in\ Audio\ Digital\ Stereo\ \(HDMI\ 3\)"
device.class = monitor
alsa.card = 0
alsa.card_name = "HDA\ Intel\ PCH"
alsa.long_card_name = "HDA\ Intel\ PCH\ at\ 0x51130000\ irq\ 136"
alsa.driver_name = snd_hda_intel
device.bus_path = pci-0000:00:1f.3
sysfs.path = /devices/pci0000:00/0000:00:1f.3/sound/card0
device.bus = pci
device.vendor.id = 8086
device.vendor.name = "Intel\ Corporation"
device.product.id = a348
device.product.name = "Cannon\ Lake\ PCH\ cAVS"
device.form_factor = internal
device.string = 0
module-udev-detect.discovered = 1
device.icon_name = audio-card-pci
is-default = false
gst-launch-1.0 pulsesrc device=alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra2.monitor ! ...
Device found:
name : Built-in Audio Digital Stereo (HDMI 3)
class : Audio/Sink
caps : audio/x-raw, format=(string){ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, S24LE, S24BE, S24_32LE, S24_32BE, U8 }, layout=(string)interleaved, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-alaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-mulaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
properties:
alsa.resolution_bits = 16
device.api = alsa
device.class = sound
alsa.class = generic
alsa.subclass = generic-mix
alsa.name = "HDMI\ 2"
alsa.id = "HDMI\ 2"
alsa.subdevice = 0
alsa.subdevice_name = "subdevice\ \#0"
alsa.device = 8
alsa.card = 0
alsa.card_name = "HDA\ Intel\ PCH"
alsa.long_card_name = "HDA\ Intel\ PCH\ at\ 0x51130000\ irq\ 136"
alsa.driver_name = snd_hda_intel
device.bus_path = pci-0000:00:1f.3
sysfs.path = /devices/pci0000:00/0000:00:1f.3/sound/card0
device.bus = pci
device.vendor.id = 8086
device.vendor.name = "Intel\ Corporation"
device.product.id = a348
device.product.name = "Cannon\ Lake\ PCH\ cAVS"
device.form_factor = internal
device.string = "hdmi:0\,2"
device.buffering.buffer_size = 352800
device.buffering.fragment_size = 176400
device.access_mode = mmap+timer
device.profile.name = hdmi-stereo-extra2
device.profile.description = "Digital\ Stereo\ \(HDMI\ 3\)"
device.description = "Built-in\ Audio\ Digital\ Stereo\ \(HDMI\ 3\)"
module-udev-detect.discovered = 1
device.icon_name = audio-card-pci
is-default = true
gst-launch-1.0 ... ! pulsesink device=alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra2
Device found:
name : BUFFALO BSWHD06M USB Camera
class : Video/Source
caps : video/x-raw, format=(string)YUY2, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)8/1;
video/x-raw, format=(string)YUY2, width=(int)800, height=(int)600, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)640, height=(int)360, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)352, height=(int)288, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)176, height=(int)144, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)160, height=(int)120, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
image/jpeg, width=(int)1280, height=(int)960, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)12/1;
image/jpeg, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 24/1, 20/1, 16/1 };
image/jpeg, width=(int)800, height=(int)600, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 24/1, 20/1, 16/1 };
image/jpeg, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 24/1, 20/1, 16/1 };
image/jpeg, width=(int)640, height=(int)360, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
image/jpeg, width=(int)352, height=(int)288, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 24/1, 20/1, 15/1 };
image/jpeg, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
image/jpeg, width=(int)176, height=(int)144, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
image/jpeg, width=(int)160, height=(int)120, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 24/1, 20/1, 16/1 };
properties:
udev-probed = true
device.bus_path = pci-0000:00:14.0-usb-0:10:1.0
sysfs.path = /sys/devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10:1.0/video4linux/video0
device.bus = usb
device.subsystem = video4linux
device.vendor.id = 0411
device.vendor.name = "KYE\\x20Systems\\x20Corp."
device.product.id = 0260
device.product.name = "BUFFALO\ BSWHD06M\ USB\ Camera"
device.serial = KYE_Systems_Corp._BUFFALO_BSWHD06M_USB_Camera
device.capabilities = :capture:
device.api = v4l2
device.path = /dev/video0
v4l2.device.driver = uvcvideo
v4l2.device.card = "BUFFALO\ BSWHD06M\ USB\ Camera\015\012:\ "
v4l2.device.bus_info = usb-0000:00:14.0-10
v4l2.device.version = 329746 (0x00050812)
v4l2.device.capabilities = 2225078273 (0x84a00001)
v4l2.device.device_caps = 69206017 (0x04200001)
gst-launch-1.0 v4l2src ! ...
You are not just playing the stream, you are actually re-encoding the data. This encoding introduces latency. For the x264enc element use the tune=zerolatency option to reduce the delay. It comes at a cost of video quality though.
Related
django.db.utils.DataError: value too long for type character varying(2)
I've added the following to my User model: COUNTRIES = ( ('AD', _('Andorra')), ('AE', _('United Arab Emirates')), ('AF', _('Afghanistan')), ('AG', _('Antigua & Barbuda')), ('AI', _('Anguilla')), . . . ('YU', _('Yugoslavia')), ('ZA', _('South Africa')), ('ZM', _('Zambia')), ('ZR', _('Zaire')), ('ZW', _('Zimbabwe')), ('ZZ', _('Unknown or unspecified country')), ) class CountryField(models.CharField): def __init__(self, *args, **kwargs): kwargs.setdefault('max_length', 2) kwargs.setdefault('choices', COUNTRIES) super(CountryField, self).__init__(*args, **kwargs) def get_internal_type(self): return "CharField" class User(AbstractUser): ... country = CountryField() ... This is the migration created because of this change: class Migration(migrations.Migration): dependencies = [ ('users', '0006_auto_20180207_1902'), ] operations = [ migrations.AddField( model_name='user', name='country', field=pulsemanager.users.models.CountryField(choices=[('AD', 'Andorra'), ('AE', 'United Arab Emirates'), ('AF', 'Afghanistan'), ('AG', 'Antigua & Barbuda'), ('AI', 'Anguilla'), ('AL', 'Albania'), ('AM', 'Armenia'), ('AN', 'Netherlands Antilles'), ('AO', 'Angola'), ('AQ', 'Antarctica'), ('AR', 'Argentina'), ('AS', 'American Samoa'), ('AT', 'Austria'), ('AU', 'Australia'), ('AW', 'Aruba'), ('AZ', 'Azerbaijan'), ('BA', 'Bosnia and Herzegovina'), ('BB', 'Barbados'), ('BD', 'Bangladesh'), ('BE', 'Belgium'), ('BF', 'Burkina Faso'), ('BG', 'Bulgaria'), ('BH', 'Bahrain'), ('BI', 'Burundi'), ('BJ', 'Benin'), ('BM', 'Bermuda'), ('BN', 'Brunei Darussalam'), ('BO', 'Bolivia'), ('BR', 'Brazil'), ('BS', 'Bahama'), ('BT', 'Bhutan'), ('BV', 'Bouvet Island'), ('BW', 'Botswana'), ('BY', 'Belarus'), ('BZ', 'Belize'), ('CA', 'Canada'), ('CC', 'Cocos (Keeling) Islands'), ('CF', 'Central African Republic'), ('CG', 'Congo'), ('CH', 'Switzerland'), ('CI', 'Ivory Coast'), ('CK', 'Cook Iislands'), ('CL', 'Chile'), ('CM', 'Cameroon'), ('CN', 'China'), ('CO', 'Colombia'), ('CR', 'Costa Rica'), ('CU', 'Cuba'), ('CV', 'Cape Verde'), ('CX', 'Christmas Island'), ('CY', 'Cyprus'), ('CZ', 'Czech Republic'), ('DE', 'Germany'), ('DJ', 'Djibouti'), ('DK', 'Denmark'), ('DM', 'Dominica'), ('DO', 'Dominican Republic'), ('DZ', 'Algeria'), ('EC', 'Ecuador'), ('EE', 'Estonia'), ('EG', 'Egypt'), ('EH', 'Western Sahara'), ('ER', 'Eritrea'), ('ES', 'Spain'), ('ET', 'Ethiopia'), ('FI', 'Finland'), ('FJ', 'Fiji'), ('FK', 'Falkland Islands (Malvinas)'), ('FM', 'Micronesia'), ('FO', 'Faroe Islands'), ('FR', 'France'), ('FX', 'France, Metropolitan'), ('GA', 'Gabon'), ('GB', 'United Kingdom (Great Britain)'), ('GD', 'Grenada'), ('GE', 'Georgia'), ('GF', 'French Guiana'), ('GH', 'Ghana'), ('GI', 'Gibraltar'), ('GL', 'Greenland'), ('GM', 'Gambia'), ('GN', 'Guinea'), ('GP', 'Guadeloupe'), ('GQ', 'Equatorial Guinea'), ('GR', 'Greece'), ('GS', 'South Georgia and the South Sandwich Islands'), ('GT', 'Guatemala'), ('GU', 'Guam'), ('GW', 'Guinea-Bissau'), ('GY', 'Guyana'), ('HK', 'Hong Kong'), ('HM', 'Heard & McDonald Islands'), ('HN', 'Honduras'), ('HR', 'Croatia'), ('HT', 'Haiti'), ('HU', 'Hungary'), ('ID', 'Indonesia'), ('IE', 'Ireland'), ('IL', 'Israel'), ('IN', 'India'), ('IO', 'British Indian Ocean Territory'), ('IQ', 'Iraq'), ('IR', 'Islamic Republic of Iran'), ('IS', 'Iceland'), ('IT', 'Italy'), ('JM', 'Jamaica'), ('JO', 'Jordan'), ('JP', 'Japan'), ('KE', 'Kenya'), ('KG', 'Kyrgyzstan'), ('KH', 'Cambodia'), ('KI', 'Kiribati'), ('KM', 'Comoros'), ('KN', 'St. Kitts and Nevis'), ('KP', "Korea, Democratic People's Republic of"), ('KR', 'Korea, Republic of'), ('KW', 'Kuwait'), ('KY', 'Cayman Islands'), ('KZ', 'Kazakhstan'), ('LA', "Lao People's Democratic Republic"), ('LB', 'Lebanon'), ('LC', 'Saint Lucia'), ('LI', 'Liechtenstein'), ('LK', 'Sri Lanka'), ('LR', 'Liberia'), ('LS', 'Lesotho'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('LV', 'Latvia'), ('LY', 'Libyan Arab Jamahiriya'), ('MA', 'Morocco'), ('MC', 'Monaco'), ('MD', 'Moldova, Republic of'), ('MG', 'Madagascar'), ('MH', 'Marshall Islands'), ('ML', 'Mali'), ('MN', 'Mongolia'), ('MM', 'Myanmar'), ('MO', 'Macau'), ('MP', 'Northern Mariana Islands'), ('MQ', 'Martinique'), ('MR', 'Mauritania'), ('MS', 'Monserrat'), ('MT', 'Malta'), ('MU', 'Mauritius'), ('MV', 'Maldives'), ('MW', 'Malawi'), ('MX', 'Mexico'), ('MY', 'Malaysia'), ('MZ', 'Mozambique'), ('NA', 'Namibia'), ('NC', 'New Caledonia'), ('NE', 'Niger'), ('NF', 'Norfolk Island'), ('NG', 'Nigeria'), ('NI', 'Nicaragua'), ('NL', 'Netherlands'), ('NO', 'Norway'), ('NP', 'Nepal'), ('NR', 'Nauru'), ('NU', 'Niue'), ('NZ', 'New Zealand'), ('OM', 'Oman'), ('PA', 'Panama'), ('PE', 'Peru'), ('PF', 'French Polynesia'), ('PG', 'Papua New Guinea'), ('PH', 'Philippines'), ('PK', 'Pakistan'), ('PL', 'Poland'), ('PM', 'St. Pierre & Miquelon'), ('PN', 'Pitcairn'), ('PR', 'Puerto Rico'), ('PT', 'Portugal'), ('PW', 'Palau'), ('PY', 'Paraguay'), ('QA', 'Qatar'), ('RE', 'Reunion'), ('RO', 'Romania'), ('RU', 'Russian Federation'), ('RW', 'Rwanda'), ('SA', 'Saudi Arabia'), ('SB', 'Solomon Islands'), ('SC', 'Seychelles'), ('SD', 'Sudan'), ('SE', 'Sweden'), ('SG', 'Singapore'), ('SH', 'St. Helena'), ('SI', 'Slovenia'), ('SJ', 'Svalbard & Jan Mayen Islands'), ('SK', 'Slovakia'), ('SL', 'Sierra Leone'), ('SM', 'San Marino'), ('SN', 'Senegal'), ('SO', 'Somalia'), ('SR', 'Suriname'), ('ST', 'Sao Tome & Principe'), ('SV', 'El Salvador'), ('SY', 'Syrian Arab Republic'), ('SZ', 'Swaziland'), ('TC', 'Turks & Caicos Islands'), ('TD', 'Chad'), ('TF', 'French Southern Territories'), ('TG', 'Togo'), ('TH', 'Thailand'), ('TJ', 'Tajikistan'), ('TK', 'Tokelau'), ('TM', 'Turkmenistan'), ('TN', 'Tunisia'), ('TO', 'Tonga'), ('TP', 'East Timor'), ('TR', 'Turkey'), ('TT', 'Trinidad & Tobago'), ('TV', 'Tuvalu'), ('TW', 'Taiwan, Province of China'), ('TZ', 'Tanzania, United Republic of'), ('UA', 'Ukraine'), ('UG', 'Uganda'), ('UM', 'United States Minor Outlying Islands'), ('US', 'United States of America'), ('UY', 'Uruguay'), ('UZ', 'Uzbekistan'), ('VA', 'Vatican City State (Holy See)'), ('VC', 'St. Vincent & the Grenadines'), ('VE', 'Venezuela'), ('VG', 'British Virgin Islands'), ('VI', 'United States Virgin Islands'), ('VN', 'Viet Nam'), ('VU', 'Vanuatu'), ('WF', 'Wallis & Futuna Islands'), ('WS', 'Samoa'), ('YE', 'Yemen'), ('YT', 'Mayotte'), ('YU', 'Yugoslavia'), ('ZA', 'South Africa'), ('ZM', 'Zambia'), ('ZR', 'Zaire'), ('ZW', 'Zimbabwe'), ('ZZ', 'Unknown or unspecified country')], default=django.utils.timezone.now, max_length=2), preserve_default=False, ), migrations.AlterField( model_name='user', name='last_name', field=models.CharField(blank=True, max_length=150, verbose_name='last name'), ), ] Python3 manager migrate produces this error: django.db.utils.DataError: value too long for type character varying(2) I did try changing max_length=150 in the alter above max_length=2, but it didn't help. So what am I doing wrong?
replacing a new interface with old one in tkinter
I've created a class that has a function called mainScreen(). It simply prints the main screen with two buttons on it. If you press any button, it must go to another function called signup(). I want to clear the whole frame and create new widgets but I can't clear the widgets class graphics: def __init__(self, master): self.root = master def mainscreen(self): helv36 = tkFont.Font(family='Century Gothic', size=20) mainFrame = Frame(self.root) mainFrame.config(relief='sunken', width=1280, height=720, bg='light blue') mainFrame.pack(expand='yes', fill='both') inButton = Button(mainFrame, text = "Sign up", bd = 10, relief = GROOVE, font = helv36) inButton.bind("<Button-1>", self.signup) inButton.place(bordermode = OUTSIDE, width =160, height = 60, x = 600, y = 300) upButton = Button(mainFrame, text = "Sign in", bd = 10, relief = GROOVE, font = helv36) upButton.bind("<Button-1>", self.signup) upButton.place(bordermode = OUTSIDE, width =160, height = 60, x = 600, y = 400) mainFrame.pack_propagate(FALSE) self.root.mainloop() def signup(self,event): signUpShow = Frame(self.root) signUpShow.config(relief='sunken', width=1280, height=720, bg='light yellow') signUpShow.pack(expand='yes', fill='both')
You __init__ needs to have its code indented and it needs a call to mainscreen. The solution to mainFrame being local within mainscreen is to make it also an attribute. self.mainframe = mainFrame = Frame(self.root) Then you can access self.mainframe within signup.
Python ES client deleting the doces while inserting bulk data with bulk helper
jsondata = f.read() dataList = json.loads(jsondata) projectName = dataList['query']['project'] reportStartTime = dataList['query']['startTime'] reportEndTime = dataList['query']['endTime'] allEventList = dataList['sessionEvents'] '''We need a Type for each data so it will be like startTime:endTime''' flag = False count = 0 esbulkData = [] for event in allEventList: ls = event["l"] del event["l"] for l in ls: llist = [] eventList = [] llist.append(l) event["l"] = llist eventList.append(event) flurryData = { "project": projectName, "startTime": reportStartTime, "endTime": reportEndTime, "sessionEvents": eventList } #{ # "_index": "tickets-index", # "_type": "tickets", # "_id": j, # "_source": { # "any":"data" + str(j), # "timestamp": datetime.now()} # } esData = {"_index": "fl_ios_prod_feb_bulk", "_type": "flurryRawSchema", "_id": count, "_source": flurryData} esbulkData.append(esData) es = Elasticsearch([ES_URL]) res = helpers.bulk(es, esbulkData) if (res): print("Passed") else: print("Failed") In above code, everything works just fine but doc_count don't go more than 500 while checking on "Sense". It seems to have deleted some docs. Please help. I am having those nights
Okay So I forget to increase the count and that what was issue.
Tkinter Treeview grid alignment issue
How can I make the treeview widget stick to the Noth (to the toolbar) when scaling up the application window. It sticks to the west South and Est, but not the North. using : self.tree.grid(row=1,column=0,sticky=N+W+E+S) I This is the tree.grid alignment configuration ... self.vsb = ttk.Scrollbar(master, orient=VERTICAL, command=self.tree.yview) self.hsb = ttk.Scrollbar(master, orient=HORIZONTAL, command=self.tree.xview) self.vsb.grid(row=1, column=1, sticky='ns') self.hsb.grid(row=2, column=0, sticky='ew') self.tree.configure(yscrollcommand=self.vsb.set) self.tree.configure(xscrollcommand=self.hsb.set) self.tree.grid(row=1,column=0,sticky=N+W+E+S) ... This is the toolbar grid config (in case it causes the issue) ... self.toolbar = Frame(master, bg="blue") self.upButton = Button(self.toolbar, text="Up", command=self.doNothing, padx=10, pady=10) self.upButton.grid(row=0,column=0,sticky=N+W) self.downButton = Button(self.toolbar, text="Down", command=self.doNothing, padx=10, pady=10) self.downButton.grid(row=0,column=1, sticky=N+W) self.insupButton = Button(self.toolbar, text="Insert UP", command=lambda: self.insertUp(self.tree), padx=10, pady=10) self.insupButton.grid(row=0,column=2, sticky=N+W) self.insdownButton = Button(self.toolbar, text="Insert Down", command=lambda: self.insertDown(self.tree), padx=10, pady=10) self.insdownButton.grid(row=0,column=3, sticky=N+W) self.delbrButton = Button(self.toolbar, text="Delete branch", command=lambda: self.deleteBr(self.tree), padx=10, pady=10) self.delbrButton.grid(row=0,column=4, sticky=N+W) self.deltreeButton = Button(self.toolbar, text="Delete entire tree", command=lambda: self.deleteTr(self.tree), padx=10, pady=10) self.deltreeButton.grid(row=0,column=5, sticky=N+W) self.searchButton = Button(self.toolbar, text='Search', command=lambda: self.searchTr(self.tree), padx=10, pady=10) self.searchButton.grid(row=0,column=6, sticky=N+W) self.calcButton = Button(self.toolbar, text='Calc', command=lambda: self.calcTree(self.tree), padx=10, pady=10) self.calcButton.grid(row=0,column=7, sticky=N+W) self.toolbar.grid(row=0,column=0, sticky=N+W) ... Application at launch: Observed result: Application scaled up Observed result: Application scaled down (overlaps with the toolbar) Desired result: Application scaled up
Your tree is sticking to the north, it's just that the top of the row is further down than you realize. You need to give one or more rows a weight, so that tkinter will allocate extra space to that row (and not to any rows with the default weight of zero). For example: master.grid_rowconfigure(1, weight=1) For a definitive reference to how the grid algorithm works see http://tcl.tk/man/tcl8.5/TkCmd/grid.htm#M32
R h2o gsub null pointer
I'm using the h2o package in R and trying to do some data manipulation but having some issues with the sub/gsub functions. Here's my code: library(h2o) # Start cluster localH2O = h2o.init(nthreads = 2) # Create data set dat1.mini <- structure(list(id = c("7927751403363142656", "18236986451472797696", "5654946373641778176", "14195690822403907584", "1693303484298446848", "1.1362181921561e+19", "11694645532962195456", "1221431312630614784", "1987127670789791488", "379819848497418688"), click = c("0", "0", "0", "0", "0", "0", "0", "1", "0", "0"), hour = c("14102118", "14102217", "14102812", "14102912", "14102820", "14102401", "14102117", "14102312", "14102301", "14102414"), C1 = c("1005", "1005", "1005", "1002", "1005", "1005", "1005", "1005", "1005", "1005"), banner_pos = c("1", "1", "0", "0", "0", "0", "1", "1", "0", "0"), site_id = c("b7e9786d", "e151e245", "85f751fd", "ee4c822c", "85f751fd", "85f751fd", "e5c60a05", "e151e245", "1fbe01fe", "1fbe01fe"), site_domain = c("b12b9f85", "7e091613", "c4e18dd6", "c4e18dd6", "c4e18dd6", "c4e18dd6", "7256c623", "7e091613", "f3845767", "f3845767"), site_category = c("f028772b", "f028772b", "50e219e0", "50e219e0", "50e219e0", "50e219e0", "f028772b", "f028772b", "28905ebd", "28905ebd"), app_id = c("ecad2386", "ecad2386", "685d1c4c", "ecad2386", "92f5800b", "f02cb7ab", "ecad2386", "ecad2386", "ecad2386", "ecad2386"), app_domain = c("7801e8d9", "7801e8d9", "2347f47a", "7801e8d9", "ae637522", "2347f47a", "7801e8d9", "7801e8d9", "7801e8d9", "7801e8d9"), app_category = c("07d7df22", "07d7df22", "8ded1f7a", "07d7df22", "0f2161f8", "f95efa07", "07d7df22", "07d7df22", "07d7df22", "07d7df22"), device_id = c("a99f214a", "a99f214a", "a99f214a", "8374cacf", "a99f214a", "8a5908a5", "a99f214a", "a99f214a", "a99f214a", "a99f214a"), device_ip = c("3214d61e", "d5623936", "419e166e", "698846d6", "c2d9c2f2", "40817190", "edd10fc1", "e4c6e857", "05d3adbe", "6929d972"), device_model = c("a0f5f879", "69f9dd0e", "46a414f4", "12edfe21", "4ffd3a7e", "04f5b394", "779d90c2", "1f0bc64f", "293291c1", "d787e91b"), device_type = c("1", "1", "1", "0", "1", "1", "1", "1", "1", "1"), device_conn_type = c("0", "0", "3", "0", "3", "0", "0", "0", "0", "0"), C14 = c("16208", "20277", "23224", "17566", "21189", "20633", "19771", "17264", "15703", "20108"), C15 = c("320", "320", "320", "320", "320", "320", "320", "320", "320", "320"), C16 = c("50", "50", "50", "50", "50", "50", "50", "50", "50", "50"), C17 = c("1800", "2281", "2676", "479", "2424", "2374", "2227", "1872", "1722", "2299"), C18 = c("3", "3", "0", "3", "1", "3", "0", "3", "0", "2"), C19 = c("167", "47", "35", "39", "161", "39", "679", "39", "35", "1327"), C20 = c("100077", "100181", "100176", "100074", "100189", "-1", "100074", "-1", "-1", "-1"), C21 = c("23", "42", "221", "23", "71", "23", "48", "23", "79", "52")), .Names = c("id", "click", "hour", "C1", "banner_pos", "site_id", "site_domain", "site_category", "app_id", "app_domain", "app_category", "device_id", "device_ip", "device_model", "device_type", "device_conn_type", "C14", "C15", "C16", "C17", "C18", "C19", "C20", "C21"), row.names = c(NA, 10L), class = "data.frame") # Load data to cluster dat.mini.hex <- as.h2o(localH2O, dat1.mini) # Attempt to grab substring of first 6 characters from hour column dat.mini.hex$hr <- h2o.sub('^(.{6}).*$','\\1', dat.mini.hex$hour) dat.mini.hex$hr <- h2o.gsub('(.+)..','\\1', dat.mini.hex$hour) All of these attempts result in the following error: Error in .h2o.__remoteSend(client, .h2o.__PAGE_EXEC2, str = expr) : http://127.0.0.1:54321/2/Exec2.json returned the following error: class java.lang.NullPointerException
The error occurs because hour is a numeric column. The function h2o.sub and h2o.gsub do not work with numeric data. The command str(dat.mini.hex$hour) will show you that hour is a numeric column. str(dat.mini.hex$hour) You can convert hour to a factor and save the result in a new column hour2. dat.mini.hex$hour2 <- as.factor(dat.mini.hex$hour) Now, you can use h2o.sub. However, I suppose you will not like the result... h2o.sub('^(.{6}).*$','\\1', dat.mini.hex$hour2) # hour2 # 1 \\1 # 2 \\1 # 3 \\1 # 4 \\1 # 5 \\1 # 6 \\1 As you can see, h2o.sub uses \\1 literally but not for the first matching group. This behaviour is in contrast to base R's sub. You can change your regex and replace the characters after the first six ones with the empty string. h2o.sub('(?<=^.{6}).*$','', dat.mini.hex$hour2) # hour2 # 1 141021 # 2 141022 # 3 141028 # 4 141029 # 5 141028 # 6 141024 Here, (?<=^.{6}) is a positive lookbehind. It matches the position that is preceded by the beginning of the string and the first 6 digits.